You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Antoine Pitrou (Jira)" <ji...@apache.org> on 2020/09/08 15:58:00 UTC
[jira] [Resolved] (ARROW-9864) [Python] pathlib.Path not supported
in write_to_dataset with partition columns
[ https://issues.apache.org/jira/browse/ARROW-9864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antoine Pitrou resolved ARROW-9864.
-----------------------------------
Fix Version/s: 2.0.0
Resolution: Fixed
Issue resolved by pull request 8064
[https://github.com/apache/arrow/pull/8064]
> [Python] pathlib.Path not supported in write_to_dataset with partition columns
> ------------------------------------------------------------------------------
>
> Key: ARROW-9864
> URL: https://issues.apache.org/jira/browse/ARROW-9864
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Reporter: Joris Van den Bossche
> Priority: Major
> Labels: parquet, pull-request-available
> Fix For: 2.0.0
>
> Time Spent: 2h
> Remaining Estimate: 0h
>
> Copying over from https://github.com/pandas-dev/pandas/issues/35902
> {code:python}
> import pathlib
> df = pd.DataFrame({'A':[1,2,3,4], 'B':'C'})
> df.to_parquet('tmp_path1.parquet') # OK
> df.to_parquet(pathlib.Path('tmp_path2.parquet')) # OK
> df.to_parquet('tmp_path3.parquet', partition_cols=['B']) # OK
> df.to_parquet(pathlib.Path('tmp_path4.parquet'), partition_cols=['B']) # TypeError
> {code}
> {{to_parquet}} method raises TypeError when using {{pathlib.Path()}} as an argument in case when `partition_cols` argument is not None. If no partition cols are provided, then {{pathlib.Path()}} is properly accepted
> {code}
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-53-cae5a944d982> in <module>
> 3
> 4 df.to_parquet('tmp_path3.parquet', partition_cols=['B']) # OK
> ----> 5 df.to_parquet(pathlib.Path('tmp_path4.parquet'), partition_cols=['B']) # TypeError
> ...
> ~/miniconda3/lib/python3.7/site-packages/pyarrow/parquet.py in write_to_dataset(table, root_path, partition_cols, partition_filename_cb, filesystem, **kwargs)
> 1790 subtable = pa.Table.from_pandas(subgroup, schema=subschema,
> 1791 safe=False)
> -> 1792 _mkdir_if_not_exists(fs, '/'.join([root_path, subdir]))
> 1793 if partition_filename_cb:
> 1794 outfile = partition_filename_cb(keys)
> TypeError: sequence item 0: expected str instance, PosixPath found
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)