JingsongLi commented on code in PR #8117: URL: https://github.com/apache/paimon/pull/8117#discussion_r3417623118
########## paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/ScanBucketITCase.java: ########## @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.paimon.flink; + +import org.apache.paimon.data.GenericRow; +import org.apache.paimon.data.InternalRow; +import org.apache.paimon.manifest.ManifestEntry; +import org.apache.paimon.reader.RecordReader; +import org.apache.paimon.reader.RecordReaderIterator; +import org.apache.paimon.table.FileStoreTable; +import org.apache.paimon.table.sink.BatchTableCommit; +import org.apache.paimon.table.sink.BatchTableWrite; +import org.apache.paimon.table.sink.BatchWriteBuilder; +import org.apache.paimon.table.source.DataSplit; + +import org.apache.flink.types.Row; +import org.junit.jupiter.api.Test; + +import javax.annotation.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static java.util.Collections.singletonList; +import static org.apache.paimon.testutils.assertj.PaimonAssertions.anyCauseMatches; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** ITCase for {@link org.apache.paimon.flink.FlinkConnectorOptions#SCAN_BUCKET}. */ +public class ScanBucketITCase extends CatalogITCaseBase { + + @Override + protected List<String> ddl() { + return singletonList( + "CREATE TABLE IF NOT EXISTS T (id INT, v INT, PRIMARY KEY (id) NOT ENFORCED) " + + "WITH ('bucket' = '4')"); + } + + @Nullable + @Override + protected Boolean sqlSyncMode() { + return true; + } + + @Test + public void testScanBucketFilter() throws Exception { + FileStoreTable table = paimonTable("T"); + writeRows(table, 1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80); + + int targetBucket = 0; + for (int bucket = 0; bucket < 4; bucket++) { + List<ManifestEntry> files = table.store().newScan().withBucket(bucket).plan().files(); + if (!files.isEmpty()) { + targetBucket = bucket; + break; + } + } + + List<Row> expected = readRowsFromBucket(table, targetBucket); + + List<Row> actual = Review Comment: Could we add a regression assertion for the aggregate-pushdown path here? The earlier bug was that `SELECT COUNT(*) FROM T /*+ OPTIONS('scan.bucket'='...') */` planned splits through `AggregatePushDownUtils.planSplits`, separate from the normal source path covered by `SELECT *`. The new `ScanBucketUtils.applyScanBucket` call in `AggregatePushDownUtils` fixes that path, but without an aggregate query test it can regress while this IT still passes. A small `COUNT(*)` (or `MIN`/`MAX`) assertion against the same bucket rows would cover it. -- 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]
