|
18 | 18 |
|
19 | 19 | package org.apache.paimon.table; |
20 | 20 |
|
21 | | -import org.apache.paimon.CoreOptions; |
22 | 21 | import org.apache.paimon.catalog.Identifier; |
23 | 22 | import org.apache.paimon.data.GenericRow; |
24 | 23 | import org.apache.paimon.predicate.Predicate; |
|
32 | 31 | import java.util.Set; |
33 | 32 | import java.util.stream.Collectors; |
34 | 33 |
|
| 34 | +import static org.apache.paimon.CoreOptions.BUCKET; |
| 35 | +import static org.apache.paimon.CoreOptions.BUCKET_KEY; |
35 | 36 | import static org.assertj.core.api.Assertions.assertThat; |
36 | 37 |
|
37 | 38 | /** |
|
40 | 41 | */ |
41 | 42 | public class BucketFilterScanTest extends TableTestBase { |
42 | 43 |
|
| 44 | + @Test |
| 45 | + public void testBucketFilterWithCompoundPredicateOnAppendTable() throws Exception { |
| 46 | + testBucketFilterWithCompoundPredicate(false); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testBucketFilterWithCompoundPredicateOnPkTable() throws Exception { |
| 51 | + testBucketFilterWithCompoundPredicate(true); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void testCompositeBucketFilterWithCompoundPredicateOnAppendTable() throws Exception { |
| 56 | + testCompositeBucketFilterWithCompoundPredicate(false); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void testCompositeBucketFilterWithCompoundPredicateOnPkTable() throws Exception { |
| 61 | + testCompositeBucketFilterWithCompoundPredicate(true); |
| 62 | + } |
| 63 | + |
43 | 64 | /** |
44 | 65 | * Tests bucket filtering with compound predicates on a single-field bucket key. |
45 | 66 | * |
@@ -67,18 +88,21 @@ public class BucketFilterScanTest extends TableTestBase { |
67 | 88 | * partition-b combination. |
68 | 89 | * </ol> |
69 | 90 | */ |
70 | | - @Test |
71 | | - public void testBucketFilterWithCompoundPredicate() throws Exception { |
| 91 | + private void testBucketFilterWithCompoundPredicate(boolean pk) throws Exception { |
72 | 92 | // ---- schema & table ---- |
73 | | - Schema schema = |
| 93 | + Schema.Builder builder = |
74 | 94 | Schema.newBuilder() |
75 | 95 | .column("a", DataTypes.INT()) |
76 | 96 | .column("b", DataTypes.INT()) |
77 | 97 | .column("c", DataTypes.INT()) |
78 | 98 | .partitionKeys("a") |
79 | | - .option(CoreOptions.BUCKET.key(), "10") |
80 | | - .option(CoreOptions.BUCKET_KEY.key(), "b") |
81 | | - .build(); |
| 99 | + .option(BUCKET.key(), "10"); |
| 100 | + if (pk) { |
| 101 | + builder.primaryKey("a", "b"); |
| 102 | + } else { |
| 103 | + builder.option(BUCKET_KEY.key(), "b"); |
| 104 | + } |
| 105 | + Schema schema = builder.build(); |
82 | 106 |
|
83 | 107 | Identifier tableId = identifier("test_bucket_filter"); |
84 | 108 | catalog.createTable(tableId, schema, false); |
@@ -148,18 +172,21 @@ public void testBucketFilterWithCompoundPredicate() throws Exception { |
148 | 172 | * targeting. |
149 | 173 | * </ol> |
150 | 174 | */ |
151 | | - @Test |
152 | | - public void testCompositeBucketFilterWithCompoundPredicate() throws Exception { |
| 175 | + private void testCompositeBucketFilterWithCompoundPredicate(boolean pk) throws Exception { |
153 | 176 | // ---- schema & table ---- |
154 | | - Schema schema = |
| 177 | + Schema.Builder builder = |
155 | 178 | Schema.newBuilder() |
156 | 179 | .column("a", DataTypes.INT()) |
157 | 180 | .column("b", DataTypes.INT()) |
158 | 181 | .column("c", DataTypes.INT()) |
159 | 182 | .partitionKeys("a") |
160 | | - .option(CoreOptions.BUCKET.key(), "10") |
161 | | - .option(CoreOptions.BUCKET_KEY.key(), "b,c") |
162 | | - .build(); |
| 183 | + .option(BUCKET.key(), "10"); |
| 184 | + if (pk) { |
| 185 | + builder.primaryKey("a", "b", "c"); |
| 186 | + } else { |
| 187 | + builder.option(BUCKET_KEY.key(), "b,c"); |
| 188 | + } |
| 189 | + Schema schema = builder.build(); |
163 | 190 |
|
164 | 191 | Identifier tableId = identifier("test_composite_bucket_filter"); |
165 | 192 | catalog.createTable(tableId, schema, false); |
|
0 commit comments