yihua opened a new pull request, #20834: URL: https://github.com/apache/hudi/pull/20834
### Describe the issue this Pull Request addresses closes #20823 An empty string partition value is written to `__HIVE_DEFAULT_PARTITION__` and reads back as null, but on the DataFrame read path `where p = ''` still returned the row with `p` read as `''`. `SparkHoodieTableFileIndex#tryPushDownPartitionPredicates` built the partition path from the equality literals and took the literals as the partition values, and the path formatter maps `''` to the default partition directory. ### Summary and Changelog An equality between a partition column and an empty or `__HIVE_DEFAULT_PARTITION__` string now matches no partition in the file index, as for a Spark datasource table, where the default partition reads as null. - `SparkHoodieTableFileIndex#tryPushDownPartitionPredicates` returns no partitions for such a predicate, before binding any static value. Letting it fall through to the filter-based listing instead would hit a null partition value in `Predicates$BinaryComparison` on hive-style, URL-encoded tables. - A static `INSERT OVERWRITE ... PARTITION (p = '__HIVE_DEFAULT_PARTITION__')` relied on that equality to find the partition to replace, so `ProvidesHoodieConfig` now resolves a default partition spec value with `IsNull` instead. - `TestPartitionPushDownWhenListingPaths` compares Hudi with a Spark parquet table for `p = ''`, `p = '__HIVE_DEFAULT_PARTITION__'`, `p is null`, `id = 1` and `p = 'x'`, and for a static overwrite of the default partition with no rows. It covers COW and MOR, plain, hive-style and hive-style URL-encoded paths, and both the path and the catalog table. Without the fix `p = ''` fails with `Expected Array(), but got Array([1,])`, and without the `IsNull` change the overwrite fails with `Expected Array([2,x]), but got Array([1,null], [2,x])`. ### Impact A filter on an empty string partition value now returns no rows, matching the null the same row reads back with, and Spark. No API or config change. ### Risk Level low. Only equalities with values that never name a stored partition value change behavior. ### Documentation Update none ### Contributor's checklist - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [ ] Enough context is provided in the sections above - [ ] Adequate tests were added if applicable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
