Repository navigation
[Data] Fix Hive null_fallback partitions on the pandas path - #67363
Conversation
…ARTITION__" Hive-style partitioning writes a null partition value as key=__HIVE_DEFAULT_PARTITION__. Map that sentinel to None when parsing Hive partition paths, pass None through _cast_value, and keep the partition column's type when the value is None (predicate pruning and FileBasedDatasource). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: hzmsh <[email protected]>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
When a file also contains the partition column, compare a null partition by checking that the column is all null; pc.equal returns null for null inputs. Keep the partition column's type when the file's column is null-typed, as an all-empty CSV column is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: hzmsh <[email protected]>
|
Hi @bveeramani and @goutamvenkat-anyscale, microcheck is green, and the one Cursor Bugbot finding is fixed in a1e27955cf. This PR changes |
Jadiouo
left a comment
There was a problem hiding this comment.
Verified against base 3608367 and PR head a1e2795 (Python 3.13, pyarrow 25.0.1).
- On base, a null Hive partition reads back as the
__HIVE_DEFAULT_PARTITION__string andfilter(col("year").is_null())matches 0 rows. With the PR it reads back asNoneand matches 1 row, for both parquet and CSV, including multi-level partitions.field_types={"year": int}now works instead of raisingValueError. - The new tests fail on base (6 of 7) and all pass with the PR. The rest of
test_partitioning.pyshows no new failures (6 s3-fixture errors occur on both base and the PR in my environment). - I reproduced the Bugbot finding on b759b35 and confirmed it’s fixed in a1e2795.
One question: partition_filter callbacks such as d["year"] >= "2020" now raise TypeError on a null partition, since the value is None instead of a string. The new behavior is more correct, but would it be worth a note in the release notes?
LGTM.
|
Thanks for verifying this, @Jadiouo! The |
|
@jiangxt2 could you take a look? |
Resolve conflicts with ray-project#67073 in partitioning.py and test_partitioning.py. Signed-off-by: hzmsh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Hi jiangxt2, thank you for the careful review and the clear repros! I reproduced both P2s locally and agree with all three comments. While checking the first one, I found that master has the mirror case (a file value of |
- pandas blocks (read_json with lines=True): a null partition only matches a file column that is all null. Casting None to the column's dtype turned it into False for bool columns and hid the conflict. - V1 Parquet: fill a null partition with a typed null (the field_types type, or string), so the materialized column isn't null-typed. - Update the partition value annotations and the schema docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: hzmsh <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit e9bb343. Configure here.
An all-null column is null-typed in Arrow, for example a Hive null partition's column read with read_json(lines=True) once its block is converted to Arrow. pyarrow's is_in rejects a null-typed input against a string value set, so cast the nulls to the value set's type first. The result doesn't change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: hzmsh <[email protected]>
|
hi - assigned @AarryaSaraf to take a look at this PR - thanks! |
|
hi, also - there are merge conflicts, could you fix? |
ray-project#67887 added opt-in null_fallback for Hive null partitions, which covers the parser, Parquet and the Arrow path. Keep only what it leaves out on the pandas path: a null partition vs the file column in _add_partitions_to_dataframe, and is_in on a null-typed column. Signed-off-by: hzmsh <[email protected]>
|
Thanks @richardliaw for the heads-up! I merged master into this branch to resolve the conflicts. While resolving them, I found that #67887 already covers most of this PR, so I narrowed it down:
Locally, all 8 new tests pass, existing test suites match master, and pre-commit passes. CI will run on the new push. I have also updated the title and description to match. |
abhishekverma-ray
left a comment
There was a problem hiding this comment.
Thanks, this looks good to me. I checked the fix on master vs this branch: is_in, not in and the string form filter(expr="year in ['1970']") all fail on master once blocks are converted to Arrow, and all pass here.

Summary
#67887 added opt-in
Partitioning("hive", null_fallback=HIVE_DEFAULT_PARTITION), which reads a__HIVE_DEFAULT_PARTITION__directory asNone. With it set, two cases still go wrong when a reader produces pandas blocks, for exampleread_json(..., lines=True).Before
is_inraisesArrowTypeError. On the pandas path, a null partition column is filled withNone. When that block is converted to Arrow, the all-Nonecolumn gets typenull, whichpc.is_inrejects against a non-null value set:_add_partitions_to_dataframecasts the partition values[None, ...]to the file column's dtype (column.astype(df[field].dtype)) before checking for conflicts:False:astype(bool)turnsNoneintoFalse, so the conflict is silently accepted instead of raisingValueError.astype(int)raisesTypeErrorinstead of the usual "different from in-data values"ValueError.After
_pa_is_in: a null-typed array is cast to the value set's type beforepc.is_in. This also fixesis_inon any all-Nonepandas column._add_partitions_to_dataframe: aNonepartition value is not cast; it matches only a column that is all null, the same rule [Data][Delta DSv2][1/7] Shared Parquet and partitioning fixes for the Delta reader #67887 uses in_add_partitions_to_table.Testing
Run on this branch (b5f742a) and on master (71a71b8), WSL2, PyArrow 23.0.1:
test_partitioning.pyexpressions/test_predicate.pyunit/test_expression_evaluator.pydatasource/test_json.pydatasource/test_csv.pydatasource/test_parquet.pytest_read_json_pandas_null_partition_is_in,in_data=[False],in_data=[1], andis_inwith strings on an all-null column), and 4 already pass on master (in_data=[None],in_data=[True],in_data=[None, True], andis_inwith integers on an all-null column).test_parquet.pyfailure istest_get_parquet_dataset_fs_serialization_fallback, which fails on master too in my setup.pre-commit run --files <changed files>passed.Related to #67362: with #67887,
null_fallback=HIVE_DEFAULT_PARTITIONreads the null partition asNone; this PR fixes the pandas path for it.AI assistance
Co-developed with Claude Code (Claude Opus 5.5): the investigation, the fix, the tests and this description. I reviewed every changed line and ran the test commands above locally. I also used
gemini 4 argon (high)for additional review and audit.