fix(spec): reject reserved system field names at create and alter time - #641
Open
jackylee-ch wants to merge 1 commit into
Open
fix(spec): reject reserved system field names at create and alter time#641jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
`TableSchema::validate_no_reserved_fields` already rejects the five Java `SpecialFields.SYSTEM_FIELD_NAMES` and the `_KEY_` prefix, but it is only reachable from `validate_resolved_structure`, which runs when loading an externally-supplied schema. Neither `Schema::new` nor `TableSchema::apply_changes` checked names, so `CREATE TABLE` with a column named `_ROW_ID`, `rowkind`, or `_KEY_id` was accepted and persisted through every catalog path, and the column was then silently shadowed by the system value on read. Split the name half into a free `validate_no_reserved_field_names(&[DataField])` and call it from both schema paths as well as the existing resolved-structure check. The field-id half is unchanged. `pk_hybrid_table_with_reserved_column` deliberately builds a schema carrying `_ROW_ID` to exercise the read-side guard, so it now deserializes that schema from JSON instead of going through `Schema::builder`, which is what the guard is for: metadata written by another engine.
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.
TableSchema::validate_no_reserved_fieldsalready rejects the five JavaSpecialFields.SYSTEM_FIELD_NAMES(_SEQUENCE_NUMBER,_VALUE_KIND,_LEVEL,rowkind,_ROW_ID) and the_KEY_prefix — but it is only reachable fromvalidate_resolved_structure, which runs when loading an externally-suppliedschema. Neither
Schema::newnorTableSchema::apply_changeschecked names, soCREATE TABLEwith a column named_ROW_IDwas accepted and persisted throughevery catalog path (including DataFusion DDL), and that column was then silently
shadowed by the system value on read.
Fix: split the name half into a free
validate_no_reserved_field_names(&[DataField])and call it from both schemapaths plus the existing resolved-structure check. The field-id half is unchanged.
pk_hybrid_table_with_reserved_columndeliberately builds a schema carrying_ROW_IDto exercise the read-side guard, so it now deserializes that schema fromJSON instead of going through
Schema::builder— which is precisely the case theread guard exists for: metadata written by another engine.