[ 
https://issues.apache.org/jira/browse/ARROW-12083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17309029#comment-17309029
 ] 

Weston Pace commented on ARROW-12083:
-------------------------------------

Related: ARROW-12080

Schema evolution (ARROW-11003) is also a closely related topic.

Allowing the schema to evolve as a dataset is read is challenging.  The 
single-file CSV reader does this and it comes with a fair amount of complexity 
as well as CPU cost (have to go back and cast previous chunks).  It's not even 
"single-file" with datasets though.  The streaming CSV reader uses the first 
block (typically ~1MB) of the CSV file to determine the schema.  A lot of the 
dataset scanning, project, etc. code relies on knowing the schema up front.  
It's probably an interesting question for the ML (or the query engine doc).

A pretty decent workaround is to store the evolved schema alongside your data 
files as a really short IPC or parquet file.  I believe Spark refers to these 
as "summary files".

> [R] schema use in open_dataset
> ------------------------------
>
>                 Key: ARROW-12083
>                 URL: https://issues.apache.org/jira/browse/ARROW-12083
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>    Affects Versions: 3.0.0
>         Environment: Windows
>            Reporter: Shaun Nielsen
>            Priority: Minor
>
> I have a directory of split .csvs that I'm importing with open_dataset(). 
> Between files, a column is imported as either int64 (e.g. -2) and the other 
> string (1986CD), and this throws an error when {{unify_schemas = T}}
> {{ arrow::open_dataset('./split-csvs/nswcr/', format = 'csv', unify_schemas = 
> T)}}
> {{Error: Invalid: Unable to merge: Field SEIFACalcMethod has incompatible 
> types: int64 vs string}}
> If I use the schema parameter, and only want to specify this column, I only 
> am able to import this column
> {{arrow::open_dataset('./split-csvs/nswcr/', }}{{format = 'csv', }}{{schema = 
> schema(SEIFACalcMethod = string()))}}
> {{ }}
> {{FileSystemDataset with 45 csv files}}
> {{SEIFACalcMethod: string}}
> I was expecting that could set the class of a select few columns, while the 
> rest would be imported as-is. Similar to readr::read_csv(col_types = cols()) 
> approach.
> Not sure if this is expected behaviour, a bug, or a possible avenue for 
> improvement. I've tagged this as the latter. (y)
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to