You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Shaun Nielsen (Jira)" <ji...@apache.org> on 2021/05/10 01:06:00 UTC

[jira] [Commented] (ARROW-12083) [R] schema use in open_dataset

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

Shaun Nielsen commented on ARROW-12083:
---------------------------------------

Hi all,

I still have this issue. Let me know if i've missesd something

 
{noformat}
> ds <- arrow::open_dataset(source_dir, format = 'csv', unify_schemas = T, col_types = arrow::schema(SEIFACalcMethod = arrow::string()))

#> Error: Invalid: Unable to merge: Field SEIFACalcMethod has incompatible types: int64 vs string{noformat}
 

{{It does not seem to pass on the parameter?}}

 
{noformat}
> packageVersion('arrow')
[1] ‘4.0.0’{noformat}
I attempted to write a repex (manually)

 
{noformat}
# Test dataframe, write in hive style for open_dataset
dir.create('open_dataset_test')
a_dataframe <- 
 data.frame(A = rep(c(1L,2L), each = 5),
 B = rep(c(1L,'2L'), each = 5))
dir.create('open_dataset_test/B=1')
dir.create('open_dataset_test/B=2L')
filter(a_dataframe, B == '1') %>% readr::write_csv('open_dataset_test/B=1/B=1.csv')
filter(a_dataframe, B == '2L') %>% readr::write_csv('open_dataset_test/B=2L/B=2L.csv')
# open_dataset
# * Error on unify_schemas
arrow::open_dataset(sources = 'open_dataset_test/', 
 format = 'csv', 
 unify_schemas = T)
# * schema only returns specified columns
arrow::open_dataset(sources = 'open_dataset_test/',
 format = 'csv', 
 unify_schemas = T,
 schema = arrow::schema(B = arrow::string()))
# col_types not passed on == error on unify_schemes
arrow::open_dataset(sources = 'open_dataset_test/', 
 format = 'csv', 
 unify_schemas = T,
 col_types = arrow::schema(SEIFACalcMethod = arrow::string()))
{noformat}
 

 

 

> [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)