arrow-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joris Van den Bossche (Jira)" <>
Subject [jira] [Created] (ARROW-12631) [Python] Should dataset.write_table accept a Scanner?
Date Mon, 03 May 2021 12:55:00 GMT
Joris Van den Bossche created ARROW-12631:

             Summary: [Python] Should dataset.write_table accept a Scanner?
                 Key: ARROW-12631
             Project: Apache Arrow
          Issue Type: Improvement
          Components: Python
            Reporter: Joris Van den Bossche

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:

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

You could expect to do the following?

ds.write_dataset(dataset.scanner(columns=projection), "test.parquet", format="parquet")

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

View raw message