Skip to content

Commit e02837d

Browse files
authored
[lake] Forbidden schema evolution for lake enabled tables. (#2150)
1 parent 0210da6 commit e02837d

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

fluss-lake/fluss-lake-paimon/src/test/java/org/apache/fluss/lake/paimon/LakeEnabledTableCreateITCase.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.fluss.config.ConfigOptions;
2424
import org.apache.fluss.config.Configuration;
2525
import org.apache.fluss.exception.FlussRuntimeException;
26+
import org.apache.fluss.exception.InvalidAlterTableException;
2627
import org.apache.fluss.exception.InvalidConfigException;
2728
import org.apache.fluss.exception.InvalidTableException;
2829
import org.apache.fluss.exception.LakeTableAlreadyExistException;
@@ -857,6 +858,61 @@ void testEnableLakeTableAfterAlterTableProperties() throws Exception {
857858
admin.alterTable(tablePath, Collections.singletonList(enableLake), false).get();
858859
}
859860

861+
@Test
862+
void testAlterLakeEnabledTableSchema() throws Exception {
863+
// create table
864+
TableDescriptor tableDescriptor =
865+
TableDescriptor.builder()
866+
.schema(
867+
Schema.newBuilder()
868+
.column("c1", DataTypes.INT())
869+
.column("c2", DataTypes.STRING())
870+
.build())
871+
.property(ConfigOptions.TABLE_DATALAKE_ENABLED, true)
872+
.customProperties(new HashMap<>())
873+
.distributedBy(BUCKET_NUM, "c1", "c2")
874+
.build();
875+
TablePath tablePath = TablePath.of(DATABASE, "alter_table_schema");
876+
admin.createTable(tablePath, tableDescriptor, false).get();
877+
Table paimonTable =
878+
paimonCatalog.getTable(Identifier.create(DATABASE, tablePath.getTableName()));
879+
verifyPaimonTable(
880+
paimonTable,
881+
tableDescriptor,
882+
RowType.of(
883+
new DataType[] {
884+
org.apache.paimon.types.DataTypes.INT(),
885+
org.apache.paimon.types.DataTypes.STRING(),
886+
// for __bucket, __offset, __timestamp
887+
org.apache.paimon.types.DataTypes.INT(),
888+
org.apache.paimon.types.DataTypes.BIGINT(),
889+
org.apache.paimon.types.DataTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE()
890+
},
891+
new String[] {
892+
"c1",
893+
"c2",
894+
BUCKET_COLUMN_NAME,
895+
OFFSET_COLUMN_NAME,
896+
TIMESTAMP_COLUMN_NAME
897+
}),
898+
"c1,c2",
899+
BUCKET_NUM);
900+
901+
// test alter table schema
902+
List<TableChange> tableChanges =
903+
Collections.singletonList(
904+
TableChange.addColumn(
905+
"c3",
906+
DataTypes.INT(),
907+
"c3 comment",
908+
TableChange.ColumnPosition.last()));
909+
assertThatThrownBy(() -> admin.alterTable(tablePath, tableChanges, false).get())
910+
.cause()
911+
.isInstanceOf(InvalidAlterTableException.class)
912+
.hasMessage(
913+
"Schema evolution is currently not supported for tables with datalake enabled.");
914+
}
915+
860916
private void verifyPaimonTable(
861917
Table paimonTable,
862918
TableDescriptor flussTable,

fluss-server/src/main/java/org/apache/fluss/server/coordinator/MetadataManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ public void alterTableSchema(
328328

329329
TableInfo table = getTable(tablePath);
330330

331+
// TODO: remote this after lake enable table support schema evolution, track by
332+
// https://github.com/apache/fluss/issues/2128
333+
if (table.getTableConfig().isDataLakeEnabled()) {
334+
throw new InvalidAlterTableException(
335+
"Schema evolution is currently not supported for tables with datalake enabled.");
336+
}
337+
331338
// validate the table column changes
332339
if (!schemaChanges.isEmpty()) {
333340
Schema newSchema = SchemaUpdate.applySchemaChanges(table, schemaChanges);

0 commit comments

Comments
 (0)