Skip to content

Commit 1b0c4a5

Browse files
beryllwwangjunbo
authored andcommitted
format ut
1 parent 287205c commit 1b0c4a5

File tree

2 files changed

+40
-46
lines changed

2 files changed

+40
-46
lines changed

fluss-lake/fluss-lake-iceberg/src/test/java/org/apache/fluss/lake/iceberg/IcebergLakeCatalogTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
package org.apache.fluss.lake.iceberg;
1919

20+
import org.apache.fluss.config.ConfigOptions;
2021
import org.apache.fluss.config.Configuration;
22+
import org.apache.fluss.exception.InvalidTableException;
2123
import org.apache.fluss.metadata.Schema;
2224
import org.apache.fluss.metadata.TableDescriptor;
2325
import org.apache.fluss.metadata.TablePath;
@@ -29,14 +31,19 @@
2931
import org.apache.iceberg.Table;
3032
import org.apache.iceberg.catalog.TableIdentifier;
3133
import org.apache.iceberg.types.Types;
34+
import org.assertj.core.api.Assertions;
3235
import org.junit.jupiter.api.BeforeEach;
3336
import org.junit.jupiter.api.Test;
3437
import org.junit.jupiter.api.io.TempDir;
38+
import org.junit.jupiter.params.ParameterizedTest;
39+
import org.junit.jupiter.params.provider.ValueSource;
3540

3641
import java.io.File;
42+
import java.time.Duration;
3743
import java.util.Arrays;
3844
import java.util.Collections;
3945
import java.util.HashSet;
46+
import java.util.List;
4047
import java.util.Set;
4148

4249
import static org.apache.fluss.metadata.TableDescriptor.BUCKET_COLUMN_NAME;
@@ -396,4 +403,36 @@ void rejectsLogTableWithMultipleBucketKeys() {
396403
.isInstanceOf(UnsupportedOperationException.class)
397404
.hasMessageContaining("Only one bucket key is supported for Iceberg");
398405
}
406+
407+
@ParameterizedTest
408+
@ValueSource(booleans = {false, true})
409+
void testIllegalPartitionKeyType(boolean isPrimaryKeyTable) throws Exception {
410+
TablePath t1 =
411+
TablePath.of(
412+
"test_db",
413+
isPrimaryKeyTable
414+
? "pkIllegalPartitionKeyType"
415+
: "logIllegalPartitionKeyType");
416+
Schema.Builder builder =
417+
Schema.newBuilder()
418+
.column("c0", DataTypes.STRING())
419+
.column("c1", DataTypes.BOOLEAN());
420+
if (isPrimaryKeyTable) {
421+
builder.primaryKey("c0", "c1");
422+
}
423+
List<String> partitionKeys = List.of("c1");
424+
TableDescriptor.Builder tableDescriptor =
425+
TableDescriptor.builder()
426+
.schema(builder.build())
427+
.distributedBy(1, "c0")
428+
.property(ConfigOptions.TABLE_DATALAKE_ENABLED.key(), "true")
429+
.property(ConfigOptions.TABLE_DATALAKE_FRESHNESS, Duration.ofMillis(500));
430+
tableDescriptor.partitionedBy(partitionKeys);
431+
432+
Assertions.assertThatThrownBy(
433+
() -> flussIcebergCatalog.createTable(t1, tableDescriptor.build()))
434+
.isInstanceOf(InvalidTableException.class)
435+
.hasMessage(
436+
"Iceberg partition key only support string type, c1 is not string type.");
437+
}
399438
}

fluss-lake/fluss-lake-iceberg/src/test/java/org/apache/fluss/lake/iceberg/tiering/IcebergTieringITCase.java

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.apache.fluss.config.AutoPartitionTimeUnit;
2121
import org.apache.fluss.config.ConfigOptions;
22-
import org.apache.fluss.exception.InvalidTableException;
2322
import org.apache.fluss.lake.iceberg.testutils.FlinkIcebergTieringTestBase;
2423
import org.apache.fluss.metadata.Schema;
2524
import org.apache.fluss.metadata.TableBucket;
@@ -40,9 +39,6 @@
4039
import org.apache.iceberg.data.Record;
4140
import org.junit.jupiter.api.BeforeAll;
4241
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.ValueSource;
4642

4743
import java.nio.ByteBuffer;
4844
import java.time.Duration;
@@ -57,13 +53,10 @@
5753
import java.util.Iterator;
5854
import java.util.List;
5955
import java.util.Map;
60-
import java.util.concurrent.ExecutionException;
61-
import java.util.stream.Stream;
6256

6357
import static org.apache.fluss.lake.committer.BucketOffset.FLUSS_LAKE_SNAP_BUCKET_OFFSET_PROPERTY;
6458
import static org.apache.fluss.testutils.DataTestUtils.row;
6559
import static org.assertj.core.api.Assertions.assertThat;
66-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
6760

6861
/** The ITCase for tiering into iceberg. */
6962
class IcebergTieringITCase extends FlinkIcebergTieringTestBase {
@@ -93,7 +86,7 @@ class IcebergTieringITCase extends FlinkIcebergTieringTestBase {
9386
.column("f_time", DataTypes.TIME())
9487
.column("f_char", DataTypes.CHAR(3))
9588
.column("f_bytes", DataTypes.BYTES())
96-
.primaryKey("f_date", "f_int")
89+
.primaryKey("f_int")
9790
.build();
9891

9992
private static final Schema logSchema =
@@ -285,44 +278,6 @@ void testTiering() throws Exception {
285278
}
286279
}
287280

288-
private static Stream<Arguments> tieringAllTypesWriteArgs() {
289-
return Stream.of(Arguments.of(true), Arguments.of(false));
290-
}
291-
292-
@ParameterizedTest
293-
@ValueSource(booleans = {false, true})
294-
void testTieringForAllTypes(boolean isPrimaryKeyTable) throws Exception {
295-
// create a table, write some records and wait until snapshot finished
296-
TablePath t1 =
297-
TablePath.of(
298-
DEFAULT_DB,
299-
isPrimaryKeyTable ? "pkTableForAllTypes" : "logTableForAllTypes");
300-
Schema.Builder builder =
301-
Schema.newBuilder()
302-
.column("c0", DataTypes.STRING())
303-
.column("c1", DataTypes.BOOLEAN());
304-
if (isPrimaryKeyTable) {
305-
builder.primaryKey("c0", "c1");
306-
}
307-
List<String> partitionKeys = List.of("c1");
308-
TableDescriptor.Builder tableDescriptor =
309-
TableDescriptor.builder()
310-
.schema(builder.build())
311-
.distributedBy(1, "c0")
312-
.property(ConfigOptions.TABLE_DATALAKE_ENABLED.key(), "true")
313-
.property(ConfigOptions.TABLE_DATALAKE_FRESHNESS, Duration.ofMillis(500));
314-
tableDescriptor.partitionedBy(partitionKeys);
315-
tableDescriptor.customProperties(Collections.emptyMap());
316-
tableDescriptor.properties(Collections.emptyMap());
317-
318-
assertThatThrownBy(() -> createTable(t1, tableDescriptor.build()))
319-
.isInstanceOf(ExecutionException.class)
320-
.rootCause()
321-
.isInstanceOf(InvalidTableException.class)
322-
.hasMessage(
323-
"Iceberg partition key only support string type, c1 is not string type.");
324-
}
325-
326281
private void checkDataInIcebergPrimaryKeyTable(
327282
TablePath tablePath, List<InternalRow> expectedRows) throws Exception {
328283
Iterator<Record> acturalIterator = getIcebergRecords(tablePath).iterator();

0 commit comments

Comments
 (0)