wwj6591812 commented on code in PR #8117:
URL: https://github.com/apache/paimon/pull/8117#discussion_r3385417840
##########
paimon-core/src/main/java/org/apache/paimon/table/source/ReadBuilderImpl.java:
##########
@@ -161,10 +164,42 @@ public ReadBuilder withRowRangeIndex(RowRangeIndex
rowRangeIndex) {
@Override
public ReadBuilder withBucket(int bucket) {
+ validateSpecifiedBucket(table, bucket);
this.specifiedBucket = bucket;
return this;
}
+ /**
+ * Validates bucket id before manifest pruning ({@link
InnerTableScan#withBucket(int)}). Callers
+ * such as Flink {@code scan.bucket} should route through {@link
#withBucket(int)}.
+ */
+ static void validateSpecifiedBucket(InnerTable table, int bucket) {
+ checkArgument(bucket >= 0, "Bucket id must be non-negative, but is
%s.", bucket);
+ if (!(table instanceof FileStoreTable)) {
+ throw new IllegalArgumentException(
+ "Bucket scan is only supported for FileStoreTable, but got
"
+ + table.getClass().getName());
+ }
+ FileStoreTable fileStoreTable = (FileStoreTable) table;
+ checkArgument(
+ fileStoreTable.bucketMode() == BucketMode.HASH_FIXED,
+ "Bucket scan is only supported for fixed-bucket tables, but
got bucket mode %s.",
+ fileStoreTable.bucketMode());
+ checkArgument(
+ !fileStoreTable.schema().primaryKeys().isEmpty(),
Review Comment:
Thanks for the review, @JingsongLi.
I have removed the primary-key restriction from
ReadBuilderImpl.validateSpecifiedBucket(...) to keep the core
ReadBuilder.withBucket(...) API generic for fixed-bucket append tables. The
primary-key check is now enforced inside ScanBucketUtils.applyScanBucket(...),
which is the Flink scan.bucket option path. I also updated ReadBuilderImplTest
accordingly.
--
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]