|
19 | 19 |
|
20 | 20 | import org.apache.fluss.config.AutoPartitionTimeUnit; |
21 | 21 | import org.apache.fluss.config.ConfigOptions; |
| 22 | +import org.apache.fluss.exception.InvalidTableException; |
22 | 23 | import org.apache.fluss.lake.iceberg.testutils.FlinkIcebergTieringTestBase; |
23 | 24 | import org.apache.fluss.metadata.Schema; |
24 | 25 | import org.apache.fluss.metadata.TableBucket; |
|
39 | 40 | import org.apache.iceberg.data.Record; |
40 | 41 | import org.junit.jupiter.api.BeforeAll; |
41 | 42 | import org.junit.jupiter.api.Test; |
| 43 | +import org.junit.jupiter.params.ParameterizedTest; |
| 44 | +import org.junit.jupiter.params.provider.Arguments; |
| 45 | +import org.junit.jupiter.params.provider.MethodSource; |
| 46 | +import org.junit.jupiter.params.provider.ValueSource; |
42 | 47 |
|
43 | 48 | import java.nio.ByteBuffer; |
44 | 49 | import java.time.Duration; |
|
53 | 58 | import java.util.Iterator; |
54 | 59 | import java.util.List; |
55 | 60 | import java.util.Map; |
| 61 | +import java.util.concurrent.ExecutionException; |
| 62 | +import java.util.stream.Stream; |
56 | 63 |
|
57 | 64 | import static org.apache.fluss.lake.committer.BucketOffset.FLUSS_LAKE_SNAP_BUCKET_OFFSET_PROPERTY; |
58 | 65 | import static org.apache.fluss.testutils.DataTestUtils.row; |
59 | 66 | import static org.assertj.core.api.Assertions.assertThat; |
| 67 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
60 | 68 |
|
61 | 69 | /** The ITCase for tiering into iceberg. */ |
62 | 70 | class IcebergTieringITCase extends FlinkIcebergTieringTestBase { |
@@ -86,7 +94,7 @@ class IcebergTieringITCase extends FlinkIcebergTieringTestBase { |
86 | 94 | .column("f_time", DataTypes.TIME()) |
87 | 95 | .column("f_char", DataTypes.CHAR(3)) |
88 | 96 | .column("f_bytes", DataTypes.BYTES()) |
89 | | - .primaryKey("f_int") |
| 97 | + .primaryKey("f_date", "f_int") |
90 | 98 | .build(); |
91 | 99 |
|
92 | 100 | private static final Schema logSchema = |
@@ -278,6 +286,44 @@ void testTiering() throws Exception { |
278 | 286 | } |
279 | 287 | } |
280 | 288 |
|
| 289 | + private static Stream<Arguments> tieringAllTypesWriteArgs() { |
| 290 | + return Stream.of(Arguments.of(true), Arguments.of(false)); |
| 291 | + } |
| 292 | + |
| 293 | + @ParameterizedTest |
| 294 | + @ValueSource(booleans = {false, true}) |
| 295 | + void testTieringForAllTypes(boolean isPrimaryKeyTable) throws Exception { |
| 296 | + // create a table, write some records and wait until snapshot finished |
| 297 | + TablePath t1 = |
| 298 | + TablePath.of( |
| 299 | + DEFAULT_DB, |
| 300 | + isPrimaryKeyTable ? "pkTableForAllTypes" : "logTableForAllTypes"); |
| 301 | + Schema.Builder builder = |
| 302 | + Schema.newBuilder() |
| 303 | + .column("c0", DataTypes.STRING()) |
| 304 | + .column("c1", DataTypes.BOOLEAN()); |
| 305 | + if (isPrimaryKeyTable) { |
| 306 | + builder.primaryKey("c0", "c1"); |
| 307 | + } |
| 308 | + List<String> partitionKeys = List.of("c1"); |
| 309 | + TableDescriptor.Builder tableDescriptor = |
| 310 | + TableDescriptor.builder() |
| 311 | + .schema(builder.build()) |
| 312 | + .distributedBy(1, "c0") |
| 313 | + .property(ConfigOptions.TABLE_DATALAKE_ENABLED.key(), "true") |
| 314 | + .property(ConfigOptions.TABLE_DATALAKE_FRESHNESS, Duration.ofMillis(500)); |
| 315 | + tableDescriptor.partitionedBy(partitionKeys); |
| 316 | + tableDescriptor.customProperties(Collections.emptyMap()); |
| 317 | + tableDescriptor.properties(Collections.emptyMap()); |
| 318 | + |
| 319 | + assertThatThrownBy(() -> createTable(t1, tableDescriptor.build())) |
| 320 | + .isInstanceOf(ExecutionException.class) |
| 321 | + .rootCause() |
| 322 | + .isInstanceOf(InvalidTableException.class) |
| 323 | + .hasMessage( |
| 324 | + "Iceberg partition column only support string type, c1 is not string type."); |
| 325 | + } |
| 326 | + |
281 | 327 | private void checkDataInIcebergPrimaryKeyTable( |
282 | 328 | TablePath tablePath, List<InternalRow> expectedRows) throws Exception { |
283 | 329 | Iterator<Record> acturalIterator = getIcebergRecords(tablePath).iterator(); |
|
0 commit comments