Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ protected Catalog getIcebergCatalog() {
@Override
public void createTable(TablePath tablePath, TableDescriptor tableDescriptor, Context context)
throws TableAlreadyExistException {
// validate at most one key field requirement
List<String> keys = tableDescriptor.getBucketKeys();
checkArgument(
keys.size() <= 1,
"Iceberg format supports at most one bucket key, but got: %s",
keys);

// convert Fluss table path to iceberg table
boolean isPkTable = tableDescriptor.hasPrimaryKey();
TableIdentifier icebergId = toIcebergTableIdentifier(tablePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ private Function<FileScanTask, List<String>> createPartitionExtractor(Table tabl
IntStream.range(0, partitionColCount).boxed().collect(Collectors.toList());
return task ->
partitionFieldIndices.stream()
// since currently, only string partition is supported
.map(index -> task.partition().get(index, String.class))
.map(index -> String.valueOf(task.partition().get(index, Object.class)))
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.fluss.lake.iceberg.utils;

import org.apache.fluss.annotation.Internal;
import org.apache.fluss.exception.InvalidTableException;
import org.apache.fluss.metadata.TableDescriptor;

import org.apache.iceberg.PartitionField;
Expand All @@ -28,7 +27,6 @@
import java.util.List;

import static org.apache.fluss.metadata.TableDescriptor.BUCKET_COLUMN_NAME;
import static org.apache.iceberg.types.Type.TypeID.STRING;

/** Utilities for constructing the Iceberg partition spec used by Fluss lake tiering. */
@Internal
Expand Down Expand Up @@ -61,24 +59,13 @@ private static PartitionSpec createPartitionSpec(
List<String> bucketKeys,
List<String> partitionKeys,
int bucketCount) {
if (bucketKeys.size() > 1) {
throw new UnsupportedOperationException(
"Only one bucket key is supported for Iceberg at the moment");
}

if (bucketKeys.isEmpty() && isPrimaryKeyTable) {
throw new IllegalArgumentException(
"Bucket key must be set for primary key Iceberg tables");
}

PartitionSpec.Builder builder = PartitionSpec.builderFor(icebergSchema);
for (String partitionKey : partitionKeys) {
if (!icebergSchema.findType(partitionKey).typeId().equals(STRING)) {
throw new InvalidTableException(
String.format(
"Partition key only support string type for iceberg currently. Column `%s` is not string type.",
partitionKey));
}
builder.identity(partitionKey);
}

Expand All @@ -91,6 +78,9 @@ private static PartitionSpec createPartitionSpec(
builder.identity(BUCKET_COLUMN_NAME);
}
} else {
// Use the first bucket key for Iceberg's bucket transform. For multi-key tables,
// this provides approximate scan pruning. The tiering writer explicitly assigns the
// correct bucket partition via PartitionKey regardless of how many keys are used.
builder.bucket(bucketKeys.get(0), bucketCount);
}
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.fluss.config.ConfigOptions;
import org.apache.fluss.config.Configuration;
import org.apache.fluss.exception.InvalidAlterTableException;
import org.apache.fluss.exception.InvalidTableException;
import org.apache.fluss.exception.TableAlreadyExistException;
import org.apache.fluss.exception.TableNotExistException;
import org.apache.fluss.lake.iceberg.testutils.IcebergTestUtils;
Expand All @@ -46,7 +45,6 @@
import org.apache.iceberg.catalog.SupportsNamespaces;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.types.Types;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
Expand Down Expand Up @@ -267,14 +265,9 @@ void rejectsPrimaryKeyTableWithMultipleBucketKeys() {

TablePath tablePath = TablePath.of(database, tableName);

assertThatThrownBy(
() ->
flussIcebergCatalog.createTable(
tablePath,
tableDescriptor,
new TestingLakeCatalogContext()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Iceberg format supports at most one bucket key");
// Multi-bucket-key tables should now create successfully
flussIcebergCatalog.createTable(
tablePath, tableDescriptor, new TestingLakeCatalogContext());
}

@Test
Expand Down Expand Up @@ -479,15 +472,9 @@ void rejectsLogTableWithMultipleBucketKeys() {

TablePath tablePath = TablePath.of(database, tableName);

// Do not allow multiple bucket keys for log table
assertThatThrownBy(
() ->
flussIcebergCatalog.createTable(
tablePath,
tableDescriptor,
new TestingLakeCatalogContext()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Iceberg format supports at most one bucket key");
// Multi-bucket-key log tables should now create successfully
flussIcebergCatalog.createTable(
tablePath, tableDescriptor, new TestingLakeCatalogContext());
}

@ParameterizedTest
Expand Down Expand Up @@ -515,15 +502,9 @@ void testIllegalPartitionKeyType(boolean isPrimaryKeyTable) throws Exception {
.property(ConfigOptions.TABLE_DATALAKE_FRESHNESS, Duration.ofMillis(500));
tableDescriptor.partitionedBy(partitionKeys);

Assertions.assertThatThrownBy(
() ->
flussIcebergCatalog.createTable(
t1,
tableDescriptor.build(),
new TestingLakeCatalogContext()))
.isInstanceOf(InvalidTableException.class)
.hasMessage(
"Partition key only support string type for iceberg currently. Column `c1` is not string type.");
// Non-string partition keys should now be supported via identity transform
flussIcebergCatalog.createTable(
t1, tableDescriptor.build(), new TestingLakeCatalogContext());
}

@Test
Expand Down
Loading