|
23 | 23 | import org.apache.fluss.config.ConfigOptions; |
24 | 24 | import org.apache.fluss.config.Configuration; |
25 | 25 | import org.apache.fluss.exception.FlussRuntimeException; |
| 26 | +import org.apache.fluss.exception.InvalidAlterTableException; |
26 | 27 | import org.apache.fluss.exception.InvalidConfigException; |
27 | 28 | import org.apache.fluss.exception.InvalidTableException; |
28 | 29 | import org.apache.fluss.exception.LakeTableAlreadyExistException; |
@@ -857,6 +858,61 @@ void testEnableLakeTableAfterAlterTableProperties() throws Exception { |
857 | 858 | admin.alterTable(tablePath, Collections.singletonList(enableLake), false).get(); |
858 | 859 | } |
859 | 860 |
|
| 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 | + |
860 | 916 | private void verifyPaimonTable( |
861 | 917 | Table paimonTable, |
862 | 918 | TableDescriptor flussTable, |
|
0 commit comments