jackylee-ch opened a new pull request, #620:
URL: https://github.com/apache/paimon-rust/pull/620
### Purpose
An explicit `bucket-key` is never validated against the table schema. A
typo'd or
stale column name resolves to no field index in `TableWrite` (built with a
lenient
`filter_map`), 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 option was worse: `bucket_key()` returned
`Some(vec![""])`,
which also suppressed the primary-key fallback.
### Brief change log
- `CoreOptions::bucket_key()`: drop blank entries, return `None` when nothing
remains, so the primary-key fallback applies as in Java.
- New `Schema::validate_bucket_keys`, 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.
- Wired into both `Schema::new` (create) and `TableSchema::apply_changes`
(alter).
The repeated-key check has no direct Java counterpart (Java compares sets);
it is
included to stay consistent with `validate_sequence_field`, which already
rejects
the analogous `sequence.field` case.
### Tests
7 new unit tests in `spec/schema.rs` covering unknown / repeated /
partitioned /
non-primary-key bucket keys, a blank option falling back to the primary
keys, the
same check on the ALTER path, and one positive case guarding against
over-rejection. Verified non-vacuous: disabling the two call sites and the
blank
filter fails 6 of the 7.
```
cargo fmt --all -- --check
# clean
cargo clippy --locked --all-targets --workspace --features fulltext,vortex
# 0 warnings
cargo test -p paimon --all-targets --features fulltext,vortex
# 2228 passed
cargo test -p paimon-rest-server
# 8 passed
rustup run 1.91.0 cargo check -p paimon --all-targets --features
fulltext,vortex # MSRV ok
```
`cargo test -p paimon-datafusion` shows 7 `TableNotExist` failures locally,
but they
reproduce identically on unmodified `main` — that suite needs `make
docker-up`,
which I did not run. No existing test needed changing.
### API and Format
No API or format change. This does tighten CREATE/ALTER on tables that were
previously accepted, but any such table was already writing everything to
bucket 0.
### Documentation
None needed; the new rules match documented Java behaviour.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]