Skip to content

[core] Reject unsafe MULTISET element evolution at DDL time - #10291

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-086-multiset-evolve
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-086-multiset-evolve

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

Altering the element type (or element nullability) of a MULTISET column threw a misleading ColumnNotExistException: the nested type-update walk in NestedSchemaUtils had no MULTISET case, so an off-by-one routed the change to updateLastColumn on an empty list. A MULTISET<T> is physically stored as InternalMap<T, Int>, so the element is a map key, and the read-side cast infrastructure (SchemaEvolutionUtil) has no MULTISET executor and createMapCastExecutor deliberately 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. The MULTISET column's own top-level nullability change (the column, not its element) is unaffected and keeps working.

This closes #10290.

Tests

  • NestedSchemaUtilsTest asserts that changing a multiset element type, element nullability, or a complex multiset element is rejected with the clear message (testMultisetElementTypeChangeRejected, ...NullabilityChangeRejected, ...OfComplexTypeRejected).
  • testMultisetTypeUpdateNullability pins that the multiset column's own nullability change still applies.

API and Format

No.

Documentation

No.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Altering a MULTISET column's element type fails with a misleading ColumnNotExistException

1 participant