Repository navigation
Conversation
…dates and times Hudi writes the partition path of a DATE column as an ISO date such as 2024-02-29. Its SQL key generator writes a TIMESTAMP column as a date and time in the default time zone of the writer's JVM with the colons escaped, such as 2024-02-29 10%3A30%3A00. The path based extractor read both as numbers, so the first commit of a table partitioned by such a column failed with a NumberFormatException. A DATE value that is not a number is now parsed as an ISO date into days since epoch. A TIMESTAMP value that is not a number is unescaped and parsed as a date and time with an optional offset, into the precision of the field, or micros when the field declares none. A value without an offset is read in the JVM's default time zone for TIMESTAMP and in UTC for TIMESTAMP_NTZ. Numbers are read as before. The tests parse twelve paths: dates before and after the epoch as dates and as numbers, and timestamps that are escaped, carry a fraction or an offset, are numbers, or have millis, micros or no declared precision, with and without a time zone. Another test expects an invalid date and a timestamp without a time to fail with a PartitionValuesExtractorException. Hudi's SQL key generator truncates the partition path of a TIMESTAMP column to whole seconds, so rows whose values differ below the second share a path and a file group. The value parsed from the path is then not the value of every row of the file. A target that fills an identity partition column from the partition value, as Iceberg does, returned the truncated value for every row and pruned filters on the column by it. No single partition value is right for a file that holds several, and a value taken from the column stats would differ from the one the file is later removed under, which is parsed from the path again. The data file extractor therefore keeps the path value and checks every file it adds stats to: for an identity partition on a TIMESTAMP or TIMESTAMP_NTZ column with a non-null value, the min and the max of the column's stats have to equal the partition value. Otherwise it throws a PartitionValuesExtractorException that names the file, the range of the column and the path value, and suggests partitioning by a column of whole seconds or a coarser value. A file without stats for the column is kept, since a Hudi table indexes only some columns in the metadata table, 32 by default, and a table written with drop.partition.columns stores no footer stats for the column. The tests keep a file whose only value is the path value, for TIMESTAMP, TIMESTAMP_NTZ, a null partition and a file without stats, and expect the refusal for a single value with fractional seconds and for two values of one second.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important Read
Closes #1047, part of #722.
What is the purpose of the pull request
The path based partition values extractor parses DATE partition paths written as ISO dates and TIMESTAMP paths written as escaped dates and times, instead of failing with a NumberFormatException. Since Hudi's SQL key generator truncates a TIMESTAMP path to whole seconds, a data file whose column stats show a value other than its path value is refused rather than published with a wrong partition value.
Brief change log
PathBasedPartitionValuesExtractorparses both forms into the field's precision; numbers are read as before.HudiDataFileExtractorchecks the stats of identity TIMESTAMP partition columns.Known limitations:
Verify this pull request
This change added tests and can be verified as follows:
TestHudiPartitionValuesExtractorparses twelve paths: dates before and after the epoch as dates and as numbers, and timestamps that are escaped, carry a fraction or an offset, are numbers, or have millis, micros or no declared precision, with and without a time zone; invalid values fail with aPartitionValuesExtractorException.TestHudiDataFileExtractorkeeps a file whose only value is the path value, a null partition and a file without stats for the column, and refuses a value with fractional seconds and two values of one second.xtable-coreunit tests pass (3 skipped), thextable-coreIceberg ITs pass, and the Iceberg table format's 26 unit tests and 46 ITs pass (1 skipped).