Skip to content

fix(spec): validate bucket-key against table schema - #620

Open
jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix/validate-bucket-key
Open

fix(spec): validate bucket-key against table schema#620
jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix/validate-bucket-key

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Jul 27, 2026

Copy link
Copy Markdown

bucket-key is never validated against the schema. A typo'd or stale key resolves
to no field index in TableWrite (a lenient filter_map lookup), so
bucket_key_indices ends up empty and the assigner falls through to
ConstantBucketAssigner(0): every row silently lands in bucket 0 instead of being
hashed. A blank value was worse — bucket_key() returned Some(vec![""]), which
also suppressed the primary-key fallback.

Fix: validate bucket-key at create and alter time, mirroring Java
TableSchema#originalBucketKeys — each key must exist, 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 and an all-blank value resolves to None, so the
primary-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.

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.
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.

1 participant