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 @@ -69,7 +69,6 @@ public class PaimonConversions {
static {
PAIMON_UNSETTABLE_OPTIONS.add(CoreOptions.BUCKET.key());
PAIMON_UNSETTABLE_OPTIONS.add(CoreOptions.BUCKET_KEY.key());
PAIMON_UNSETTABLE_OPTIONS.add(CoreOptions.PATH.key());
PAIMON_UNSETTABLE_OPTIONS.add(PARTITION_GENERATE_LEGACY_NAME_OPTION_KEY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.fluss.config.ConfigOptions;
import org.apache.fluss.config.Configuration;
import org.apache.fluss.exception.FlussRuntimeException;
import org.apache.fluss.exception.InvalidAlterTableException;
import org.apache.fluss.exception.InvalidConfigException;
import org.apache.fluss.exception.InvalidTableException;
import org.apache.fluss.exception.LakeTableAlreadyExistException;
Expand Down Expand Up @@ -390,6 +391,8 @@ void testCreateLakeEnabledTableWithAllTypes() throws Exception {

@Test
void testCreateLakeEnableTableWithUnsettablePaimonOptions() {
assertThat(PAIMON_UNSETTABLE_OPTIONS).doesNotContain(CoreOptions.PATH.key());

Map<String, String> customProperties = new HashMap<>();

for (String key : PAIMON_UNSETTABLE_OPTIONS) {
Expand Down Expand Up @@ -418,6 +421,67 @@ void testCreateLakeEnableTableWithUnsettablePaimonOptions() {
}
}

@Test
void testAlterPaimonPathOnlyWhenLakeDisabled() throws Exception {
TableDescriptor lakeDisabledTable =
TableDescriptor.builder()
.schema(
Schema.newBuilder()
.column("c1", DataTypes.INT())
.column("c2", DataTypes.STRING())
.build())
.property(ConfigOptions.TABLE_DATALAKE_ENABLED, false)
.distributedBy(BUCKET_NUM, "c1", "c2")
.build();
TablePath lakeDisabledTablePath = TablePath.of(DATABASE, "alter_paimon_path_disabled");
admin.createTable(lakeDisabledTablePath, lakeDisabledTable, false).get();

String customPaimonPath =
Files.createTempDirectory("alter-paimon-path-disabled").toUri().toString();
admin.alterTable(
lakeDisabledTablePath,
Collections.singletonList(TableChange.set("paimon.path", customPaimonPath)),
false)
.get();
assertThat(
admin.getTableInfo(lakeDisabledTablePath)
.get()
.toTableDescriptor()
.getCustomProperties())
.containsEntry("paimon.path", customPaimonPath);

TableDescriptor lakeEnabledTable =
TableDescriptor.builder()
.schema(
Schema.newBuilder()
.column("c1", DataTypes.INT())
.column("c2", DataTypes.STRING())
.build())
.property(ConfigOptions.TABLE_DATALAKE_ENABLED, true)
.distributedBy(BUCKET_NUM, "c1", "c2")
.build();
TablePath lakeEnabledTablePath = TablePath.of(DATABASE, "alter_paimon_path_enabled");
admin.createTable(lakeEnabledTablePath, lakeEnabledTable, false).get();

assertThatThrownBy(
() ->
admin.alterTable(
lakeEnabledTablePath,
Collections.singletonList(
TableChange.set(
"paimon.path",
Files.createTempDirectory(
"alter-paimon-path-enabled")
.toUri()
.toString())),
false)
.get())
.cause()
.isInstanceOf(InvalidAlterTableException.class)
.hasMessageContaining(
"'paimon.path' can only be altered when datalake is disabled");
}

@Test
void testCreateLakeEnableTableWithExistLakeTable() throws Exception {
Map<String, String> customProperties = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,10 @@ public void alterTableProperties(
TableInfo tableInfo = tableReg.toTableInfo(tablePath, schemaInfo);

// validate the changes
validateAlterTableProperties(tableInfo, tablePropertyChanges.tableKeysToChange());
validateAlterTableProperties(
tableInfo,
tablePropertyChanges.tableKeysToChange(),
tablePropertyChanges.customKeysToChange());

TableDescriptor tableDescriptor = tableInfo.toTableDescriptor();
TableDescriptor newDescriptor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
/** Validator of {@link TableDescriptor}. */
public class TableDescriptorValidation {

private static final String PAIMON_PATH_KEY = "paimon.path";

private static final Set<String> SYSTEM_COLUMNS =
Collections.unmodifiableSet(
new LinkedHashSet<>(
Expand Down Expand Up @@ -155,6 +157,11 @@ private static void checkTableLakeFormatMatchesCluster(

public static void validateAlterTableProperties(
TableInfo currentTable, Set<String> tableKeysToChange) {
validateAlterTableProperties(currentTable, tableKeysToChange, Collections.emptySet());
}

public static void validateAlterTableProperties(
TableInfo currentTable, Set<String> tableKeysToChange, Set<String> customKeysToChange) {
TableConfig currentConfig = currentTable.getTableConfig();

List<String> unsupportedKeys =
Expand All @@ -179,6 +186,13 @@ public static void validateAlterTableProperties(
ConfigOptions.TABLE_KV_STANDBY_REPLICA_ENABLED.key()));
}

if (customKeysToChange.contains(PAIMON_PATH_KEY) && currentConfig.isDataLakeEnabled()) {
throw new InvalidAlterTableException(
String.format(
"'%s' can only be altered when datalake is disabled.",
PAIMON_PATH_KEY));
}

if (!currentConfig.getDataLakeFormat().isPresent()) {
List<String> datalakeKeys =
tableKeysToChange.stream()
Expand Down