[core] Reject unsafe MULTISET element evolution at DDL time - #10291
Open
LuciferYang wants to merge 1 commit into
Open
LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
A multiset element is physically a map key. A map key type cannot be cast on read (see SchemaEvolutionUtil#createMapCastExecutor), and a MULTISET-to-MULTISET cast cannot be resolved at all, so evolving a multiset element (type or nullability) is not read-safe. NestedSchemaUtils used to descend into the element and generate the change, which then either failed with a misleading ColumnNotExistException (master) or silently broke reads of existing data files. Reject any multiset element change in handleMultisetTypeUpdate with a clear message instead.
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.
Purpose
Altering the element type (or element nullability) of a
MULTISETcolumn threw a misleadingColumnNotExistException: the nested type-update walk inNestedSchemaUtilshad noMULTISETcase, so an off-by-one routed the change toupdateLastColumnon an empty list. AMULTISET<T>is physically stored asInternalMap<T, Int>, so the element is a map key, and the read-side cast infrastructure (SchemaEvolutionUtil) has no MULTISET executor andcreateMapCastExecutordeliberately forbids changing a map key type. So a multiset element type change cannot be applied to existing data.This rejects a multiset element modification at DDL time with a clear, actionable message ("Cannot update the element type of MULTISET column ... a multiset element is a map key, whose type cannot be evolved") instead of the misleading
ColumnNotExistException. TheMULTISETcolumn's own top-level nullability change (the column, not its element) is unaffected and keeps working.This closes #10290.
Tests
NestedSchemaUtilsTestasserts that changing a multiset element type, element nullability, or a complex multiset element is rejected with the clear message (testMultisetElementTypeChangeRejected,...NullabilityChangeRejected,...OfComplexTypeRejected).testMultisetTypeUpdateNullabilitypins that the multiset column's own nullability change still applies.API and Format
No.
Documentation
No.