Indian-boult opened a new pull request, #1012: URL: https://github.com/apache/incubator-xtable/pull/1012
Fixes #641. ## What is the purpose of the pull request The Iceberg spec makes `column_sizes`, `value_counts`, `null_value_counts`, `nan_value_counts` and the lower and upper bounds optional in a data file. `IcebergColumnStatsConverter.fromIceberg` only checked `value_counts` and read the other maps directly, so a sync from an Iceberg table whose writer leaves one out failed with a `NullPointerException`. The trace in the issue fails at the column size lookup, so the Snowflake data file had value and null counts but no column size. The converter now accepts a missing map or a missing key for each metric: - No null count: the field gets no `ColumnStat`, which is what already happens when its value count is missing. `ColumnStat.numNulls` is a `long`, so the only other choice is 0, and the Delta, Iceberg and Hudi targets all write `numNulls` as a known null count. A 0 would let Delta and Iceberg skip the file for `IS NULL` filters even when it holds nulls. The cost is that the column's bounds are dropped as well. - No column size: `totalSize` is 0. No target uses it for pruning, and it is already 0 for the Delta and Paimon sources, which do not track it. - No lower or upper bound: that side of the `Range` is null, as it already was for a missing key. The converter does not read NaN counts, so they need no change. ## Brief change log - `IcebergColumnStatsConverter.fromIceberg`: skip fields without a null count, use 0 for a missing column size, and treat a missing bounds map like a missing key. - `TestIcebergColumnStatsConverter`: cases for null column sizes, a missing null count, null bound maps and a mix of missing metrics. - `TestIcebergConversionSource#testSyncToDeltaWithMissingColumnStats`: appends an Iceberg data file without column sizes and with null counts for two columns only, syncs it to Delta through `ConversionController`, and checks the Delta stats. ## Verify this pull request This change added tests and can be verified as follows: - On `main`, the five new tests fail with `NullPointerException`. The end-to-end test fails with the same stack as the issue, from `ConversionController.sync` down to `IcebergColumnStatsConverter.java:106`. - With the fix, the sync succeeds. The Delta stats list `minValues`, `maxValues` and `nullCount` only for the two columns with a null count. `cs_quantity` has bounds but no null count, and it gets no Delta stats. - The end-to-end test uses the Delta Kernel target so it runs without Spark. The failure happens in the Iceberg source before any Delta code runs, and both Delta targets write one `nullCount` per `ColumnStat`. - `./mvnw -pl xtable-core -Dtest='TestIcebergColumnStatsConverter,TestIcebergConversionSource' test` under JDK 11: 14/14 pass. - `./mvnw -pl xtable-core test` under JDK 11: 586 tests, 0 failures, 0 errors, 3 skipped. -- 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]
