fix(spec): validate bucket-key against table schema - #620
Open
jackylee-ch wants to merge 1 commit into
Open
Conversation
An explicit `bucket-key` was never checked against the schema. A stale or typo'd column name resolved to no field index in `TableWrite` (`bucket_key_indices` is built with a lenient `filter_map`), which falls through to the `bucket_key_indices.is_empty()` branch and installs a constant bucket 0 assigner, so every row silently lands in one bucket instead of being hashed. A blank option was worse: `bucket_key()` returned `Some(vec![""])`, which also suppressed the primary-key fallback. Validate `bucket-key` at create and alter time, mirroring Java `TableSchema#originalBucketKeys`: every key must exist in the schema, must not repeat, must not be a partition field, and on a primary-key table must be part of the primary key. Blank entries are dropped when parsing the option and an all-blank value resolves to `None`, so the primary-key fallback applies as it does in Java.
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.
bucket-keyis never validated against the schema. A typo'd or stale key resolvesto no field index in
TableWrite(a lenientfilter_maplookup), sobucket_key_indicesends up empty and the assigner falls through toConstantBucketAssigner(0): every row silently lands in bucket 0 instead of beinghashed. A blank value was worse —
bucket_key()returnedSome(vec![""]), whichalso suppressed the primary-key fallback.
Fix: validate
bucket-keyat create and alter time, mirroring JavaTableSchema#originalBucketKeys— each key must exist, must not repeat, must notbe a partition field, and on a primary-key table must be part of the primary key.
Blank entries are dropped and an all-blank value resolves to
None, so theprimary-key fallback applies as in Java.
This rejects table definitions that were previously accepted, but any such table
was already writing everything to bucket 0.