Repository navigation
Fixing schema handling in arrow-parquet - #5307
Conversation
|
@TomAugspurger might you have a chance to look at this? |
|
@TomAugspurger - Thanks for reviewing this. This is meant to address #5252, but I am actually still unsure if we should really be changing the default setting for
In pyarrow, the local file metadata does not seem to include a schema with the "correct" type when there is no data in the corresponding column (unless you explicitely specify the schema during the write). Note that @bluecoconut suggested that we try to detect/specify the correct arrow schema in a more automated way (during the write). This may be a better approach than the |
|
I spent a bit of time implementing a fix for the null-schema issue on the The central issue here is that the dataframe for each partition is used to define the pyarrow schema for each partition. This is fine for most datatypes, but causes an issue when there is an empty column with Overall, I think the current |
|
@TomAugspurger The current state of the PR does not close all of #5252, but it should close the "schema" component (there is also a repartition-failure discussed there). Overall, I think the current implementation is a reasonable workaround for the schema-validation failure. |
pandas-dev/pandas#27949 may interest you :) Since that's likely to land in pandas 1.0 (and hopefully pyarrow can use it shortly after), putting in workarounds here doesn't seem worth it. The changes here look nice. Thanks @rjzamora. |
Addresses the arrow + parquet "schema" bug discussed in issue#5252.
When a dask-dataframe partition includes a column with all values missing, the corresponding parquet file for that partition (when written) will not include schema information for the correct column type (because there is no data). This leads
pyarrowto throw a schema-validation error inParquetDataset. This can be avoided by setting (by default)"validate_schema"=Falsein the special case that a shared"_metadata"file is available.If the user actually want the schema to be vaidated for each file/partition, they can still pass
dataset={"validate_schema": True}as a kwarg toread_parquet.Note that this PR also fixes a small (but important) bug in
_determine_dataset_parts(pathsvsallpathsmistake)cc @bluecoconut
black dask/flake8 dask