-
|
I want to create an external table from a CSV file using SQL like this: CREATE EXTERNAL TABLE IF NOT EXISTS region (
r_regionkey BIGINT,
r_name VARCHAR,
r_comment VARCHAR,
r_rev VARCHAR,
customer_filed VARCHAR,
) STORED AS CSV LOCATION '../region.tbl' OPTIONS ('format.delimiter' '|', 'format.has_header' 'false');When I select data from this table, I get an error: I know the |
Beta Was this translation helpful? Give feedback.
Answered by
Jefffrey
Nov 18, 2025
Replies: 1 comment
-
|
You can use the datafusion/datafusion/common/src/config.rs Lines 2792 to 2801 in 82181ac For example: datafusion-cli (main)$ cat ~/Downloads/test.csv
name_1,num,"Column Name"
andrew,100,1
jorge,200,2
andy,150,3
paul,300,4
datafusion-cli (main)$ cargo run
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
Running `/Users/jeffrey/.cargo_target_cache/debug/datafusion-cli`
DataFusion CLI v51.0.0
> CREATE EXTERNAL TABLE IF NOT EXISTS test (
name_1 VARCHAR,
num INT,
"Column Name" INT,
col123 INT,
) STORED AS CSV LOCATION '/Users/jeffrey/Downloads/test.csv' OPTIONS (
'format.delimiter' ',',
'format.truncated_rows' 'true',
'format.has_header' 'true'
);
0 row(s) fetched.
Elapsed 0.037 seconds.
> select * from test;
+--------+-----+-------------+--------+
| name_1 | num | Column Name | col123 |
+--------+-----+-------------+--------+
| andrew | 100 | 1 | NULL |
| jorge | 200 | 2 | NULL |
| andy | 150 | 3 | NULL |
| paul | 300 | 4 | NULL |
+--------+-----+-------------+--------+
4 row(s) fetched.
Elapsed 0.036 seconds. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Jefffrey
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
truncated_rowsconfig:datafusion/datafusion/common/src/config.rs
Lines 2792 to 2801 in 82181ac