[
https://issues.apache.org/jira/browse/ARROW-12631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17338359#comment-17338359
]
David Li commented on ARROW-12631:
----------------------------------
[~jorisvandenbossche] I agree the write method should also take a scanner. It's
essentially a convenience, but would be useful. You can get the schema in the
last case with {{Scanner.projected_schema}} already, but it saves some digging
& perhaps on the C++ side we could eventually do something smarter if we know
it's a scanner. (For instance, I recall there are issues about preserving
partitioning info when round-tripping a dataset.)
> [Python] Should dataset.write_table accept a Scanner?
> -----------------------------------------------------
>
> Key: ARROW-12631
> URL: https://issues.apache.org/jira/browse/ARROW-12631
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Python
> Reporter: Joris Van den Bossche
> Priority: Major
> Labels: dataset
>
> Assume you open a dataset and want to write it back with some projected
> columns. Currently you need to actually materialize it to a Table or convert
> it to an iterator of batches, for being able to write the dataset:
> {code:python}
> import pyarrow.dataset as ds
> dataset = ds.dataset(pa.table({'a': [1, 2, 3]}))
> # write with projected columns
> projection = {'b': ds.field('a')}
> # this works but materializes full table
> ds.write_dataset(dataset.to_table(columns=projection), "test.parquet",
> format="parquet")
> # this requires the exact schema, which is a bit annoying as you need to
> construct that manually
> ds.write_dataset(dataset.to_batches(columns=projection), "test.parquet",
> format="parquet", schema=...<projected schema>...)
> {code}
> You could expect to do the following?
> {code}
> ds.write_dataset(dataset.scanner(columns=projection), "test.parquet",
> format="parquet")
> {code}
> cc [~lidavidm] do you think this logic is correct?
> (encountered this while trying to reproduce ARROW-12620 in Python)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)