GitHub user Jefffrey closed the discussion with a comment: What if create table 
schema not match CSV file schema?

You can use the `truncated_rows` config:

https://github.com/apache/datafusion/blob/82181ac48c1cdc5fe1baadc7d043837acbaf35f1/datafusion/common/src/config.rs#L2792-L2801

For example:

```sh
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.
```

GitHub link: 
https://github.com/apache/datafusion/discussions/13997#discussioncomment-14995732

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to