Repository navigation
[1015] Read Paimon column stats by the schema each data file was written with - #1016
Open
Indian-boult wants to merge 3 commits into
Open
Indian-boult wants to merge 3 commits into
Indian-boult wants to merge 3 commits into
Conversation
…ten with Paimon stores a data file's value stats by position in the schema the file was written with (DataFileMeta#schemaId). When valueStatsCols is null, the Paimon source used the positions of the snapshot schema instead. After a schema change, files written before it were read with the wrong layout: - After ADD COLUMN, the sync failed with "Mismatch between column stats names and values arity". - After DROP COLUMN b and ADD COLUMN c, c got the stats of b. Iceberg then skipped those files for c IS NULL, although c is null in all their rows. - After a column type change, the old values were read with the new type. Resolve the file's schema by schemaId, match its columns to the snapshot schema by field id, and skip a column whose type changed. Fixes apache#1015
…schemas The file schemas are passed as a map filled as files are read. When a file was written with the schema the stats are reported in, its columns map by name without the match by field id. Adds a test for a column dropped and added again under the same name.
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.
Fixes #1015
What is the purpose of the pull request
The Paimon source read each data file's stats by position in the snapshot schema, but Paimon stores them by position in the schema the file was written with. After a schema change this failed the sync (
ADD COLUMN) or gave a column the stats of another column (DROPthenADD, or a type change). This PR reads the stats by the file's schema and matches columns by field id.Brief change log
PaimonDataFileExtractor: look up the schema of each data file byDataFileMeta#schemaId(), reading each schema once per sync call, and pass it to the stats extractor.PaimonStatsExtractor.extractColumnStats: whenvalueStatsCols()is null, take the column names from the file's schema. Match the file's columns to the snapshot schema by field id. Skip a column that was dropped, or whose type or type parameters changed.TestPaimonStatsExtractor: add a column (append and primary-key tables), rename then add, drop then add, and a type change. Each writes a file before the change and checks its stats after.Verify this pull request
This change added tests and can be verified as follows:
Mismatch between column stats names and values arity, the drop and add test reports stats forcfromb, and the type change test reports stats foraandffrom the old types../mvnw -pl xtable-core test: 586 tests, 0 failures, 0 errors, 3 skipped../mvnw -pl xtable-core -DskipUTs -Dit.test='ITConversionController#testVariousOperations' verify: 28 tests, 0 failures, 0 errors.c IS NULLreturned 0 rows on the drop and add table. After the fix all syncs succeed andc IS NULLreturns 2 rows.