World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2668] feat(all): Support updating default value of column (#2673)
charliecheng6300157e217268b
diff --git a/api/src/main/java/com/datastrato/gravitino/rel/TableChange.java b/api/src/main/java/com/datastrato/gravitino/rel/TableChange.javaindex 03e3955a7f..886b7c4e6c 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/TableChange.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/TableChange.java@@ -338,6 +338,21 @@ public interface TableChange {return new RenameColumn(fieldName, newName);}+ /**+ * Create a TableChange for updating the default value of a field.+ *+ * <p>The name is used to find the field to update.+ *+ * <p>If the field does not exist, the change will result in an {@link IllegalArgumentException}.+ *+ * @param fieldName The field name of the column to update.+ * @param newDefaultValue The new default value.+ * @return A TableChange for the update.+ */+ static TableChange updateColumnDefaultValue(String[] fieldName, Expression newDefaultValue) {+ return new UpdateColumnDefaultValue(fieldName, newDefaultValue);+ }+/*** Create a TableChange for updating the type of a field that is nullable.*@@ -1123,6 +1138,71 @@ public interface TableChange {}}+ /**+ * A TableChange to update the default of a field.+ *+ * <p>The field names are used to find the field to update.+ *+ * <p>If the field does not exist, the change must result in an {@link IllegalArgumentException}.+ */+ final class UpdateColumnDefaultValue implements ColumnChange {+ private final String[] fieldName;+ private final Expression newDefaultValue;++ private UpdateColumnDefaultValue(String[] fieldName, Expression newDefaultValue) {+ this.fieldName = fieldName;+ this.newDefaultValue = newDefaultValue;+ }++ /**+ * Retrieves the field name of the column whose default value is being updated.+ *+ * @return An array of strings representing the field name.+ */+ @Override+ public String[] fieldName() {+ return fieldName;+ }++ /**+ * Retrieves the new default value for the column.+ *+ * @return The new default value of the column.+ */+ public Expression getNewDefaultValue() {+ return newDefaultValue;+ }++ /**+ * Compares this UpdateColumnDefaultValue instance with another object for equality. The+ * comparison is based on the field name array and the new default value.+ *+ * @param o The object to compare with this instance.+ * @return true if the given object represents the same default value update; false otherwise.+ */+ @Override+ public boolean equals(Object o) {+ if (this == o) return true;+ if (o == null || getClass() != o.getClass()) return false;+ UpdateColumnDefaultValue that = (UpdateColumnDefaultValue) o;+ return Arrays.equals(fieldName, that.fieldName)+ && Objects.equals(newDefaultValue, that.newDefaultValue);+ }++ /**+ * Generates a hash code for this UpdateColumnDefaultValue instance. The hash code is based on+ * both the hierarchical field name and the new default value.+ *+ * @return A hash code value for this default value update operation.+ */+ @Override+ public int hashCode() {+ int result = Objects.hash(newDefaultValue);+ result = 31 * result + Arrays.hashCode(fieldName);+ return result;+ }+ }+/*** A TableChange to update the type of a field.*diff --git a/api/src/test/java/com/datastrato/gravitino/TestTableChange.java b/api/src/test/java/com/datastrato/gravitino/TestTableChange.javaindex cf195c861d..f7e22f711a 100644--- a/api/src/test/java/com/datastrato/gravitino/TestTableChange.java+++ b/api/src/test/java/com/datastrato/gravitino/TestTableChange.java@@ -21,9 +21,12 @@ import com.datastrato.gravitino.rel.TableChange.RenameColumn;import com.datastrato.gravitino.rel.TableChange.RenameTable;import com.datastrato.gravitino.rel.TableChange.SetProperty;import com.datastrato.gravitino.rel.TableChange.UpdateColumnComment;+import com.datastrato.gravitino.rel.TableChange.UpdateColumnDefaultValue;import com.datastrato.gravitino.rel.TableChange.UpdateColumnPosition;import com.datastrato.gravitino.rel.TableChange.UpdateColumnType;import com.datastrato.gravitino.rel.TableChange.UpdateComment;+import com.datastrato.gravitino.rel.expressions.Expression;+import com.datastrato.gravitino.rel.expressions.literals.Literals;import com.datastrato.gravitino.rel.types.Type;import com.datastrato.gravitino.rel.types.Types;import org.junit.jupiter.api.Test;@@ -203,6 +206,28 @@ public class TestTableChange {assertFalse(updateColumnType.nullable());}+ @Test+ public void testUpdateColumnDefaultValue() {+ String[] fieldName = {"existing_column"};+ Expression newDefaultValue = Literals.of("Default Value", Types.VarCharType.of(255));+ UpdateColumnDefaultValue updateColumnDefaultValue =+ (UpdateColumnDefaultValue) TableChange.updateColumnDefaultValue(fieldName, newDefaultValue);++ assertArrayEquals(fieldName, updateColumnDefaultValue.fieldName());+ assertEquals(newDefaultValue, updateColumnDefaultValue.getNewDefaultValue());+ }++ @Test+ public void testUpdateNestedColumnDefaultValue() {+ String[] fieldName = {"nested", "existing_column"};+ Expression newDefaultValue = Literals.of("Default Value", Types.VarCharType.of(255));+ UpdateColumnDefaultValue updateColumnType =+ (UpdateColumnDefaultValue) TableChange.updateColumnDefaultValue(fieldName, newDefaultValue);++ assertArrayEquals(fieldName, updateColumnType.fieldName());+ assertEquals(newDefaultValue, updateColumnType.getNewDefaultValue());+ }+@Testpublic void testUpdateColumnType() {String[] fieldName = {"existing_column"};@@ -359,6 +384,39 @@ public class TestTableChange {assertNotEquals(columnA.hashCode(), columnB.hashCode());}+ @Test+ void testUpdateColumnDefaultValueEqualsAndHashCode() {+ String[] nameA = {"Column Name"};+ Expression newDefaultValueA = Literals.of("Default Value", Types.VarCharType.of(255));+ UpdateColumnDefaultValue columnA =+ (UpdateColumnDefaultValue) TableChange.updateColumnDefaultValue(nameA, newDefaultValueA);+ String[] nameB = {"Column Name"};+ Expression newDefaultValueB = Literals.of("Default Value", Types.VarCharType.of(255));+ UpdateColumnDefaultValue columnB =+ (UpdateColumnDefaultValue) TableChange.updateColumnDefaultValue(nameB, newDefaultValueB);++ assertTrue(columnA.equals(columnB));+ assertTrue(columnB.equals(columnA));+ assertEquals(columnA.hashCode(), columnB.hashCode());+ }++ @Test+ void testUpdateColumnDefaultValueNotEqualsAndHashCode() {+ String[] nameA = {"Column Name A"};+ Expression newDefaultValueA = Literals.of("New Default Value A", Types.VarCharType.of(255));+ UpdateColumnDefaultValue columnA =+ (UpdateColumnDefaultValue) TableChange.updateColumnDefaultValue(nameA, newDefaultValueA);+ String[] nameB = {"Column Name B"};+ Expression newDefaultValueB = Literals.of("New Default Value B", Types.VarCharType.of(255));+ UpdateColumnDefaultValue columnB =+ (UpdateColumnDefaultValue) TableChange.updateColumnDefaultValue(nameB, newDefaultValueB);++ assertFalse(columnA.equals(null));+ assertFalse(columnA.equals(columnB));+ assertFalse(columnB.equals(columnA));+ assertNotEquals(columnA.hashCode(), columnB.hashCode());+ }+@Testvoid testColumnUpdateTypeEqualsAndHashCode() {String[] nameA = {"First Name"};diff --git a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.javaindex d5979278c0..a44519ae3f 100644--- a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java+++ b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java@@ -596,6 +596,11 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas"Hive does not support altering column nullability");}+ if (c instanceof TableChange.UpdateColumnDefaultValue) {+ throw new IllegalArgumentException(+ "Hive does not support altering column default value");+ }+if (c instanceof TableChange.UpdateColumnPosition&& afterPartitionColumn(partitionFields, ((TableChange.UpdateColumnPosition) c).getPosition())) {@@ -805,6 +810,10 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas} else if (change instanceof TableChange.UpdateColumnType) {doUpdateColumnType(cols, (TableChange.UpdateColumnType) change);+ } else if (change instanceof TableChange.UpdateColumnDefaultValue) {+ throw new IllegalArgumentException(+ "Hive does not support altering column default value");+} else if (change instanceof TableChange.UpdateColumnAutoIncrement) {throw new IllegalArgumentException("Hive does not support altering column auto increment");diff --git a/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/TestHiveTable.java b/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/TestHiveTable.javaindex ab69b82d19..6555bed0d1 100644--- a/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/TestHiveTable.java+++ b/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/TestHiveTable.java@@ -512,6 +512,17 @@ public class TestHiveTable extends MiniHiveMetastoreService {+ "but the current Gravitino Hive catalog only supports Hive 2.x"),"The exception message is: " + exception.getMessage());+ TableChange tableChange9 =+ TableChange.updateColumnDefaultValue(+ new String[] {"col_1"}, Literals.of("0", Types.ByteType.get()));+ exception =+ Assertions.assertThrows(+ IllegalArgumentException.class,+ () -> tableCatalog.alterTable(tableIdentifier, tableChange9));++ Assertions.assertEquals(+ "Hive does not support altering column default value", exception.getMessage());+// test altertableCatalog.alterTable(tableIdentifier,diff --git a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.javaindex a8c815138e..ef7486e3e3 100644--- a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java+++ b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java@@ -305,6 +305,12 @@ public class MysqlTableOperations extends JdbcTableOperations {lazyLoadTable = getOrCreateTable(databaseName, tableName, lazyLoadTable);TableChange.RenameColumn renameColumn = (TableChange.RenameColumn) change;alterSql.add(renameColumnFieldDefinition(renameColumn, lazyLoadTable));+ } else if (change instanceof TableChange.UpdateColumnDefaultValue) {+ lazyLoadTable = getOrCreateTable(databaseName, tableName, lazyLoadTable);+ TableChange.UpdateColumnDefaultValue updateColumnDefaultValue =+ (TableChange.UpdateColumnDefaultValue) change;+ alterSql.add(+ updateColumnDefaultValueFieldDefinition(updateColumnDefaultValue, lazyLoadTable));} else if (change instanceof TableChange.UpdateColumnType) {lazyLoadTable = getOrCreateTable(databaseName, tableName, lazyLoadTable);TableChange.UpdateColumnType updateColumnType = (TableChange.UpdateColumnType) change;@@ -637,6 +643,25 @@ public class MysqlTableOperations extends JdbcTableOperations {return "DROP COLUMN " + BACK_QUOTE + col + BACK_QUOTE;}+ private String updateColumnDefaultValueFieldDefinition(+ TableChange.UpdateColumnDefaultValue updateColumnDefaultValue, JdbcTable jdbcTable) {+ if (updateColumnDefaultValue.fieldName().length > 1) {+ throw new UnsupportedOperationException(MYSQL_NOT_SUPPORT_NESTED_COLUMN_MSG);+ }+ String col = updateColumnDefaultValue.fieldName()[0];+ JdbcColumn column = getJdbcColumnFromTable(jdbcTable, col);+ StringBuilder sqlBuilder = new StringBuilder(MODIFY_COLUMN + col);+ JdbcColumn newColumn =+ JdbcColumn.builder()+ .withName(col)+ .withType(column.dataType())+ .withNullable(column.nullable())+ .withComment(column.comment())+ .withDefaultValue(updateColumnDefaultValue.getNewDefaultValue())+ .build();+ return appendColumnDefinition(newColumn, sqlBuilder).toString();+ }+private String updateColumnTypeFieldDefinition(TableChange.UpdateColumnType updateColumnType, JdbcTable jdbcTable) {if (updateColumnType.fieldName().length > 1) {diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.javaindex 464c0e8e8b..5e2e3c0440 100644--- a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java+++ b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java@@ -11,6 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;import com.datastrato.gravitino.Catalog;import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.Namespace;+import com.datastrato.gravitino.auth.AuthConstants;import com.datastrato.gravitino.catalog.jdbc.config.JdbcConfig;import com.datastrato.gravitino.catalog.mysql.integration.test.service.MysqlService;import com.datastrato.gravitino.client.GravitinoMetalake;@@ -202,6 +203,41 @@ public class CatalogMysqlIT extends AbstractIT {return new Column[] {col1, col2, col3};}+ private Column[] createColumnsWithDefaultValue() {+ return new Column[] {+ Column.of(+ MYSQL_COL_NAME1,+ Types.FloatType.get(),+ "col_1_comment",+ false,+ false,+ Literals.of("1.23", Types.FloatType.get())),+ Column.of(+ MYSQL_COL_NAME2,+ Types.TimestampType.withoutTimeZone(),+ "col_2_comment",+ false,+ false,+ FunctionExpression.of("current_timestamp")),+ Column.of(+ MYSQL_COL_NAME3, Types.VarCharType.of(255), "col_3_comment", true, false, Literals.NULL),+ Column.of(+ MYSQL_COL_NAME4,+ Types.IntegerType.get(),+ "col_4_comment",+ false,+ false,+ Literals.of("1000", Types.IntegerType.get())),+ Column.of(+ MYSQL_COL_NAME5,+ Types.DecimalType.of(3, 2),+ "col_5_comment",+ true,+ false,+ Literals.of("1.23", Types.DecimalType.of(3, 2)))+ };+ }+private Map<String, String> createProperties() {Map<String, String> properties = Maps.newHashMap();properties.put(GRAVITINO_ENGINE_KEY, "InnoDB");@@ -667,6 +703,52 @@ public class CatalogMysqlIT extends AbstractIT {});}+ @Test+ void testUpdateColumnDefaultValue() {+ Column[] columns = createColumnsWithDefaultValue();+ Table table =+ catalog+ .asTableCatalog()+ .createTable(+ NameIdentifier.of(metalakeName, catalogName, schemaName, tableName),+ columns,+ null,+ ImmutableMap.of());++ Assertions.assertEquals(AuthConstants.ANONYMOUS_USER, table.auditInfo().creator());+ Assertions.assertNull(table.auditInfo().lastModifier());+ catalog+ .asTableCatalog()+ .alterTable(+ NameIdentifier.of(metalakeName, catalogName, schemaName, tableName),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[0].name()}, Literals.of("1.2345", Types.FloatType.get())),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[1].name()}, FunctionExpression.of("current_timestamp")),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[2].name()}, Literals.of("hello", Types.VarCharType.of(255))),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[3].name()}, Literals.of("2000", Types.IntegerType.get())),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[4].name()}, Literals.of("2.34", Types.DecimalType.of(3, 2))));++ table =+ catalog+ .asTableCatalog()+ .loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, tableName));++ Assertions.assertEquals(+ Literals.of("1.2345", Types.FloatType.get()), table.columns()[0].defaultValue());+ Assertions.assertEquals(+ FunctionExpression.of("current_timestamp"), table.columns()[1].defaultValue());+ Assertions.assertEquals(+ Literals.of("hello", Types.VarCharType.of(255)), table.columns()[2].defaultValue());+ Assertions.assertEquals(+ Literals.of("2000", Types.IntegerType.get()), table.columns()[3].defaultValue());+ Assertions.assertEquals(+ Literals.of("2.34", Types.DecimalType.of(3, 2)), table.columns()[4].defaultValue());+ }+@Testvoid testDropMySQLDatabase() {String schemaName = GravitinoITUtils.genRandomName("mysql_schema").toLowerCase();diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/MysqlTableOperationsIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/MysqlTableOperationsIT.javaindex 06d212472d..0d577eadfe 100644--- a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/MysqlTableOperationsIT.java+++ b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/MysqlTableOperationsIT.java@@ -425,6 +425,90 @@ public class MysqlTableOperationsIT extends TestMysqlAbstractIT {exception.getMessage().contains("with null default value cannot be changed to not null"));}+ @Test+ public void testAlterTableUpdateColumnDefaultValue() {+ String tableName = RandomNameUtils.genRandomName("properties_table_");+ String tableComment = "test_comment";+ List<JdbcColumn> columns = new ArrayList<>();+ columns.add(+ JdbcColumn.builder()+ .withName("col_1")+ .withType(Types.DecimalType.of(10, 2))+ .withComment("test_decimal")+ .withNullable(false)+ .withDefaultValue(Literals.decimalLiteral(Decimal.of("0.00", 10, 2)))+ .build());+ columns.add(+ JdbcColumn.builder()+ .withName("col_2")+ .withType(Types.LongType.get())+ .withNullable(false)+ .withDefaultValue(Literals.longLiteral(0L))+ .withComment("long type")+ .build());+ columns.add(+ JdbcColumn.builder()+ .withName("col_3")+ .withType(Types.TimestampType.withoutTimeZone())+ // MySQL 5.7 doesn't support nullable timestamp+ .withNullable(false)+ .withComment("timestamp")+ .withDefaultValue(Literals.timestampLiteral(LocalDateTime.parse("2013-01-01T00:00:00")))+ .build());+ columns.add(+ JdbcColumn.builder()+ .withName("col_4")+ .withType(Types.VarCharType.of(255))+ .withNullable(false)+ .withComment("varchar")+ .withDefaultValue(Literals.of("hello", Types.VarCharType.of(255)))+ .build());+ Map<String, String> properties = new HashMap<>();++ Index[] indexes =+ new Index[] {+ Indexes.createMysqlPrimaryKey(new String[][] {{"col_2"}}),+ Indexes.unique("uk_col_4", new String[][] {{"col_4"}})+ };+ // create table+ TABLE_OPERATIONS.create(+ TEST_DB_NAME,+ tableName,+ columns.toArray(new JdbcColumn[0]),+ tableComment,+ properties,+ null,+ Distributions.NONE,+ indexes);++ JdbcTable loaded = TABLE_OPERATIONS.load(TEST_DB_NAME, tableName);+ assertionsTableInfo(tableName, tableComment, columns, properties, indexes, loaded);++ TABLE_OPERATIONS.alterTable(+ TEST_DB_NAME,+ tableName,+ TableChange.updateColumnDefaultValue(+ new String[] {columns.get(0).name()},+ Literals.decimalLiteral(Decimal.of("1.23", 10, 2))),+ TableChange.updateColumnDefaultValue(+ new String[] {columns.get(1).name()}, Literals.longLiteral(1L)),+ TableChange.updateColumnDefaultValue(+ new String[] {columns.get(2).name()},+ Literals.timestampLiteral(LocalDateTime.parse("2024-04-01T00:00:00"))),+ TableChange.updateColumnDefaultValue(+ new String[] {columns.get(3).name()}, Literals.of("world", Types.VarCharType.of(255))));++ loaded = TABLE_OPERATIONS.load(TEST_DB_NAME, tableName);+ Assertions.assertEquals(+ Literals.decimalLiteral(Decimal.of("1.234", 10, 2)), loaded.columns()[0].defaultValue());+ Assertions.assertEquals(Literals.longLiteral(1L), loaded.columns()[1].defaultValue());+ Assertions.assertEquals(+ Literals.timestampLiteral(LocalDateTime.parse("2024-04-01T00:00:00")),+ loaded.columns()[2].defaultValue());+ Assertions.assertEquals(+ Literals.of("world", Types.VarCharType.of(255)), loaded.columns()[3].defaultValue());+ }+@Testpublic void testCreateAndLoadTable() {String tableName = RandomStringUtils.randomAlphabetic(16) + "_cl_table";diff --git a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.javaindex 04f3501664..44b09f588e 100644--- a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java+++ b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java@@ -255,6 +255,12 @@ public class PostgreSqlTableOperations extends JdbcTableOperations {} else if (change instanceof TableChange.RenameColumn) {TableChange.RenameColumn renameColumn = (TableChange.RenameColumn) change;alterSql.add(renameColumnFieldDefinition(renameColumn, tableName));+ } else if (change instanceof TableChange.UpdateColumnDefaultValue) {+ lazyLoadTable = getOrCreateTable(schemaName, tableName, lazyLoadTable);+ TableChange.UpdateColumnDefaultValue updateColumnDefaultValue =+ (TableChange.UpdateColumnDefaultValue) change;+ alterSql.add(+ updateColumnDefaultValueFieldDefinition(updateColumnDefaultValue, lazyLoadTable));} else if (change instanceof TableChange.UpdateColumnType) {lazyLoadTable = getOrCreateTable(schemaName, tableName, lazyLoadTable);TableChange.UpdateColumnType updateColumnType = (TableChange.UpdateColumnType) change;@@ -449,6 +455,36 @@ public class PostgreSqlTableOperations extends JdbcTableOperations {+ ";";}+ private String updateColumnDefaultValueFieldDefinition(+ TableChange.UpdateColumnDefaultValue updateColumnDefaultValue, JdbcTable jdbcTable) {+ if (updateColumnDefaultValue.fieldName().length > 1) {+ throw new UnsupportedOperationException(POSTGRESQL_NOT_SUPPORT_NESTED_COLUMN_MSG);+ }+ String col = updateColumnDefaultValue.fieldName()[0];+ JdbcColumn column =+ (JdbcColumn)+ Arrays.stream(jdbcTable.columns())+ .filter(c -> c.name().equals(col))+ .findFirst()+ .orElse(null);+ if (null == column) {+ throw new NoSuchColumnException("Column %s does not exist.", col);+ }++ StringBuilder sqlBuilder = new StringBuilder(ALTER_TABLE + jdbcTable.name());+ sqlBuilder+ .append("\n")+ .append(ALTER_COLUMN)+ .append(PG_QUOTE)+ .append(col)+ .append(PG_QUOTE)+ .append(" SET DEFAULT ")+ .append(+ columnDefaultValueConverter.fromGravitino(+ updateColumnDefaultValue.getNewDefaultValue()));+ return sqlBuilder.append(";").toString();+ }+private String updateColumnTypeFieldDefinition(TableChange.UpdateColumnType updateColumnType, JdbcTable jdbcTable) {if (updateColumnType.fieldName().length > 1) {diff --git a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.javaindex 0c760570db..2a8dcc230b 100644--- a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java+++ b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java@@ -210,6 +210,34 @@ public class CatalogPostgreSqlIT extends AbstractIT {};}+ private Column[] columnsWithDefaultValue() {+ return new Column[] {+ Column.of(+ "col_1",+ Types.FloatType.get(),+ "col_1_comment",+ false,+ false,+ FunctionExpression.of("random")),+ Column.of("col_2", Types.VarCharType.of(255), "col_2_comment", true, false, Literals.NULL),+ Column.of("col_3", Types.StringType.get(), "col_3_comment", false, false, null),+ Column.of(+ "col_4",+ Types.IntegerType.get(),+ "col_4_comment",+ true,+ false,+ Literals.integerLiteral(1000)),+ Column.of(+ "col_5",+ Types.TimestampType.withoutTimeZone(),+ "col_5_comment",+ true,+ false,+ Literals.NULL)+ };+ }+@Testvoid testCreateTableWithSpecialColumnNames() {// Create table from Gravitino API@@ -747,6 +775,51 @@ public class CatalogPostgreSqlIT extends AbstractIT {Literals.integerLiteral(1000), createdTable.columns()[5].defaultValue());}+ @Test+ void testUpdateColumnDefaultValue() {+ Column[] columns = columnsWithDefaultValue();+ Table table =+ catalog+ .asTableCatalog()+ .createTable(+ NameIdentifier.of(metalakeName, catalogName, schemaName, tableName),+ columns,+ table_comment,+ createProperties());+ Assertions.assertEquals(AuthConstants.ANONYMOUS_USER, table.auditInfo().creator());+ Assertions.assertNull(table.auditInfo().lastModifier());+ catalog+ .asTableCatalog()+ .alterTable(+ NameIdentifier.of(metalakeName, catalogName, schemaName, tableName),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[0].name()}, Literals.of("1.234", Types.FloatType.get())),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[1].name()}, Literals.of("hello", Types.VarCharType.of(255))),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[2].name()}, Literals.of("world", Types.StringType.get())),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[3].name()}, Literals.of(2000, Types.IntegerType.get())),+ TableChange.updateColumnDefaultValue(+ new String[] {columns[4].name()}, FunctionExpression.of("current_timestamp")));++ table =+ catalog+ .asTableCatalog()+ .loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, tableName));++ Assertions.assertEquals(+ Literals.of("1.234", Types.FloatType.get()), table.columns()[0].defaultValue());+ Assertions.assertEquals(+ Literals.of("hello", Types.VarCharType.of(255)), table.columns()[1].defaultValue());+ Assertions.assertEquals(+ Literals.of("world", Types.StringType.get()), table.columns()[2].defaultValue());+ Assertions.assertEquals(+ Literals.of(2000, Types.IntegerType.get()), table.columns()[3].defaultValue());+ Assertions.assertEquals(+ FunctionExpression.of("current_timestamp"), table.columns()[4].defaultValue());+ }+@Testvoid testColumnDefaultValueConverter() {// test convert from MySQL to Gravitinodiff --git a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/PostgreSqlTableOperationsIT.java b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/PostgreSqlTableOperationsIT.javaindex 823aef74f9..5d897bf75d 100644--- a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/PostgreSqlTableOperationsIT.java+++ b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/PostgreSqlTableOperationsIT.java@@ -124,6 +124,8 @@ public class PostgreSqlTableOperationsIT extends TestPostgreSqlAbstractIT {TableChange.updateColumnComment(new String[] {columns.get(0).name()}, "test_new_comment"),TableChange.updateColumnType(new String[] {columns.get(1).name()}, Types.DecimalType.of(10, 2)),+ TableChange.updateColumnDefaultValue(+ new String[] {columns.get(3).name()}, Literals.of("new hello world", VARCHAR)),TableChange.deleteColumn(new String[] {columns.get(2).name()}, true));load = TABLE_OPERATIONS.load(TEST_DB_NAME, newName);List<JdbcColumn> alterColumns = new ArrayList<JdbcColumn>();@@ -142,7 +144,13 @@ public class PostgreSqlTableOperationsIT extends TestPostgreSqlAbstractIT {.withNullable(false).withComment("set test key").build());- alterColumns.add(columns.get(3));+ alterColumns.add(+ JdbcColumn.builder()+ .withName("col_4")+ .withType(VARCHAR)+ .withDefaultValue(Literals.of("new hello world", VARCHAR))+ .withNullable(false)+ .build());alterColumns.add(newColumn);alterColumns.add(newColumn1);assertionsTableInfo(newName, tableComment, alterColumns, properties, null, load);@@ -169,7 +177,13 @@ public class PostgreSqlTableOperationsIT extends TestPostgreSqlAbstractIT {.withNullable(false).withComment("set test key").build());- alterColumns.add(columns.get(3));+ alterColumns.add(+ JdbcColumn.builder()+ .withName("col_4")+ .withType(VARCHAR)+ .withDefaultValue(Literals.of("new hello world", VARCHAR))+ .withNullable(false)+ .build());alterColumns.add(newColumn);alterColumns.add(newColumn1);assertionsTableInfo(newName, tableComment, alterColumns, properties, null, load);@@ -194,7 +208,13 @@ public class PostgreSqlTableOperationsIT extends TestPostgreSqlAbstractIT {.withNullable(true).withComment("set test key").build());- alterColumns.add(columns.get(3));+ alterColumns.add(+ JdbcColumn.builder()+ .withName("col_4")+ .withType(VARCHAR)+ .withDefaultValue(Literals.of("new hello world", VARCHAR))+ .withNullable(false)+ .build());alterColumns.add(newColumn);alterColumns.add(newColumn1);assertionsTableInfo(newName, tableComment, alterColumns, properties, null, load);diff --git a/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/ops/IcebergTableOpsHelper.java b/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/ops/IcebergTableOpsHelper.javaindex cbac1f03c7..07264fa67f 100644--- a/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/ops/IcebergTableOpsHelper.java+++ b/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/ops/IcebergTableOpsHelper.java@@ -259,6 +259,8 @@ public class IcebergTableOpsHelper {icebergUpdateSchema, (TableChange.UpdateColumnNullability) change);} else if (change instanceof TableChange.UpdateColumnAutoIncrement) {throw new IllegalArgumentException("Iceberg doesn't support auto increment column");+ } else if (change instanceof TableChange.UpdateColumnDefaultValue) {+ throw new IllegalArgumentException("Iceberg doesn't support update column default value");} else {throw new NotSupportedException("Iceberg doesn't support " + change.getClass().getSimpleName() + " for now");diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergIT.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergIT.javaindex e9466cff39..5d6062995b 100644--- a/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergIT.java+++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergIT.java@@ -630,6 +630,18 @@ public class CatalogIcebergIT extends AbstractIT {IllegalArgumentException.class, () -> tableCatalog.alterTable(tableIdentifier, change));Assertions.assertTrue(illegalArgumentException.getMessage().contains("no_column"));+ TableChange change2 =+ TableChange.updateColumnDefaultValue(+ new String[] {col1.name()}, Literals.of("hello", Types.StringType.get()));+ illegalArgumentException =+ assertThrows(+ IllegalArgumentException.class,+ () -> tableCatalog.alterTable(tableIdentifier, change2));+ Assertions.assertTrue(+ illegalArgumentException+ .getMessage()+ .contains("Iceberg doesn't support update column default value"));+catalog.asTableCatalog().alterTable(diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/DTOConverters.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/DTOConverters.javaindex 0544adb5b7..c109c1a53e 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/DTOConverters.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/DTOConverters.java@@ -239,6 +239,11 @@ class DTOConverters {return new TableUpdateRequest.RenameTableColumnRequest(renameColumn.fieldName(), renameColumn.getNewName());+ } else if (change instanceof TableChange.UpdateColumnDefaultValue) {+ return new TableUpdateRequest.UpdateTableColumnDefaultValueRequest(+ change.fieldName(),+ toFunctionArg(((TableChange.UpdateColumnDefaultValue) change).getNewDefaultValue()));+} else if (change instanceof TableChange.UpdateColumnType) {return new TableUpdateRequest.UpdateTableColumnTypeRequest(change.fieldName(), ((TableChange.UpdateColumnType) change).getNewDataType());diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.javaindex cc57a632a9..e7856e1247 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.java@@ -4,6 +4,8 @@*/package com.datastrato.gravitino.dto.requests;+import static com.datastrato.gravitino.rel.Column.DEFAULT_VALUE_NOT_SET;+import com.datastrato.gravitino.json.JsonUtils;import com.datastrato.gravitino.rel.Column;import com.datastrato.gravitino.rel.TableChange;@@ -45,6 +47,9 @@ import org.apache.commons.lang3.StringUtils;@JsonSubTypes.Type(value = TableUpdateRequest.RenameTableColumnRequest.class,name = "renameColumn"),+ @JsonSubTypes.Type(+ value = TableUpdateRequest.UpdateTableColumnDefaultValueRequest.class,+ name = "updateColumnDefaultValue"),@JsonSubTypes.Type(value = TableUpdateRequest.UpdateTableColumnTypeRequest.class,name = "updateColumnType"),@@ -437,6 +442,61 @@ public interface TableUpdateRequest extends RESTRequest {}}+ /** Represents a request to update the default value of a column of a table. */+ @EqualsAndHashCode+ @ToString+ class UpdateTableColumnDefaultValueRequest implements TableUpdateRequest {++ @Getter+ @JsonProperty("fieldName")+ private final String[] fieldName;++ @Getter+ @JsonProperty("newDefaultValue")+ @JsonSerialize(using = JsonUtils.ColumnDefaultValueSerializer.class)+ @JsonDeserialize(using = JsonUtils.ColumnDefaultValueDeserializer.class)+ private final Expression newDefaultValue;++ /**+ * Constructor for UpdateTableColumnDefaultValueRequest.+ *+ * @param fieldName the field name to update+ * @param newDefaultValue the new default value of the field+ */+ public UpdateTableColumnDefaultValueRequest(String[] fieldName, Expression newDefaultValue) {+ this.fieldName = fieldName;+ this.newDefaultValue = newDefaultValue;+ }++ /** Default constructor for Jackson deserialization. */+ public UpdateTableColumnDefaultValueRequest() {+ this(null, null);+ }++ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */+ @Override+ public void validate() throws IllegalArgumentException {+ Preconditions.checkArgument(+ fieldName != null+ && fieldName.length > 0+ && Arrays.stream(fieldName).allMatch(StringUtils::isNotBlank),+ "\"fieldName\" field is required and cannot be empty");+ Preconditions.checkArgument(+ (newDefaultValue != null && newDefaultValue != DEFAULT_VALUE_NOT_SET),+ "\"newDefaultValue\" field is required and cannot be empty");+ }++ /** @return An instance of TableChange. */+ @Override+ public TableChange tableChange() {+ return TableChange.updateColumnDefaultValue(fieldName, newDefaultValue);+ }+ }+/** Represents a request to update the type of a column of a table. */@EqualsAndHashCode@ToStringdiff --git a/common/src/test/java/com/datastrato/gravitino/dto/requests/TestTableUpdatesRequest.java b/common/src/test/java/com/datastrato/gravitino/dto/requests/TestTableUpdatesRequest.javaindex 7a7d9e234b..0ff4c4b982 100644--- a/common/src/test/java/com/datastrato/gravitino/dto/requests/TestTableUpdatesRequest.java+++ b/common/src/test/java/com/datastrato/gravitino/dto/requests/TestTableUpdatesRequest.java@@ -4,6 +4,8 @@*/package com.datastrato.gravitino.dto.requests;+import static com.datastrato.gravitino.rel.Column.DEFAULT_VALUE_NOT_SET;+import com.datastrato.gravitino.dto.rel.expressions.LiteralDTO;import com.datastrato.gravitino.json.JsonUtils;import com.datastrato.gravitino.rel.TableChange;@@ -27,6 +29,12 @@ public class TestTableUpdatesRequest {new TableUpdateRequest.RemoveTablePropertyRequest("key"),new TableUpdateRequest.RenameTableColumnRequest(new String[] {"oldColumn"}, "newColumn"),+ new TableUpdateRequest.UpdateTableColumnDefaultValueRequest(+ new String[] {"column"},+ LiteralDTO.builder()+ .withDataType(Types.DateType.get())+ .withValue("2023-04-01")+ .build()),new TableUpdateRequest.UpdateTableColumnTypeRequest(new String[] {"column"}, Types.StringType.get()),new TableUpdateRequest.UpdateTableColumnCommentRequest(@@ -67,6 +75,17 @@ public class TestTableUpdatesRequest {+ " \"newFieldName\": \"newColumn\"\n"+ " },\n"+ " {\n"+ + " \"@type\": \"updateColumnDefaultValue\",\n"+ + " \"fieldName\": [\n"+ + " \"column\"\n"+ + " ],\n"+ + " \"newDefaultValue\": {\n"+ + " \"type\": \"literal\",\n"+ + " \"dataType\": \"date\",\n"+ + " \"value\": \"2023-04-01\"\n"+ + " }\n"+ + " },\n"+ + " {\n"+ " \"@type\": \"updateColumnType\",\n"+ " \"fieldName\": [\n"+ " \"column\"\n"@@ -113,6 +132,24 @@ public class TestTableUpdatesRequest {setTablePropertyRequest = new TableUpdateRequest.SetTablePropertyRequest("key", "");Assertions.assertDoesNotThrow(setTablePropertyRequest::validate);++ // test validate DEFAULT_VALUE_NOT_SET or null property value+ TableUpdateRequest.UpdateTableColumnDefaultValueRequest updateTableColumnDefaultValueRequest =+ new TableUpdateRequest.UpdateTableColumnDefaultValueRequest(+ new String[] {"key"}, DEFAULT_VALUE_NOT_SET);+ Throwable exception1 =+ Assertions.assertThrows(+ IllegalArgumentException.class, updateTableColumnDefaultValueRequest::validate);+ Assertions.assertTrue(+ exception1.getMessage().contains("field is required and cannot be empty"));++ updateTableColumnDefaultValueRequest =+ new TableUpdateRequest.UpdateTableColumnDefaultValueRequest(new String[] {"key"}, null);+ Throwable exception2 =+ Assertions.assertThrows(+ IllegalArgumentException.class, updateTableColumnDefaultValueRequest::validate);+ Assertions.assertTrue(+ exception2.getMessage().contains("field is required and cannot be empty"));}@Testdiff --git a/docs/jdbc-mysql-catalog.md b/docs/jdbc-mysql-catalog.mdindex 0c3a38d956..dc0a51833b 100644--- a/docs/jdbc-mysql-catalog.md+++ b/docs/jdbc-mysql-catalog.md@@ -230,6 +230,7 @@ Gravitino supports these table alteration operations:- `UpdateColumnPosition`- `UpdateColumnNullability`- `UpdateColumnComment`+- `UpdateColumnDefaultValue`- `SetProperty`:::infodiff --git a/docs/jdbc-postgresql-catalog.md b/docs/jdbc-postgresql-catalog.mdindex 22a667e187..c33e6c0018 100644--- a/docs/jdbc-postgresql-catalog.md+++ b/docs/jdbc-postgresql-catalog.md@@ -172,6 +172,7 @@ Supports operations:- `UpdateColumnType`- `UpdateColumnNullability`- `UpdateColumnComment`+- `UpdateColumnDefaultValue`:::infoYou can't submit the `RenameTable` operation at the same time as other operations.diff --git a/docs/manage-relational-metadata-using-gravitino.md b/docs/manage-relational-metadata-using-gravitino.mdindex 5d67665d98..572d94aa3e 100644--- a/docs/manage-relational-metadata-using-gravitino.md+++ b/docs/manage-relational-metadata-using-gravitino.md@@ -822,19 +822,20 @@ Table t = tableCatalog.alterTable(NameIdentifier.of("metalake", "hive_catalog",Currently, Gravitino supports the following changes to a table:-| Supported modification | JSON | Java |-|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|-| Rename table | `{"@type":"rename","newName":"table_renamed"}` | `TableChange.rename("table_renamed")` |-| Update comment | `{"@type":"updateComment","newComment":"new_comment"}` | `TableChange.updateComment("new_comment")` |-| Set a table property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `TableChange.setProperty("key1", "value1")` |-| Remove a table property | `{"@type":"removeProperty","property":"key1"}` | `TableChange.removeProperty("key1")` |-| Add a column | `{"@type":"addColumn","fieldName":["position"],"type":"varchar(20)","comment":"Position of user","position":"FIRST","nullable": true, "autoIncrement": false, "defaultValue" : {"type": "literal", "dataType": "varchar(20)", "value": "Default Position"}}` | `TableChange.addColumn(...)` |-| Delete a column | `{"@type":"deleteColumn","fieldName": ["name"], "ifExists": true}` | `TableChange.deleteColumn(...)` |-| Rename a column | `{"@type":"renameColumn","oldFieldName":["name_old"], "newFieldName":"name_new"}` | `TableChange.renameColumn(...)` |-| Update the column comment | `{"@type":"updateColumnComment", "fieldName": ["name"], "newComment": "new comment"}` | `TableChange.updateColumnCommment(...)` |-| Update the type of a column | `{"@type":"updateColumnType","fieldName": ["name"], "newType":"varchar(100)"}` | `TableChange.updateColumnType(...)` |-| Update the nullability of a column | `{"@type":"updateColumnNullability","fieldName": ["name"],"nullable":true}` | `TableChange.updateColumnNullability(...)` |-| Update the position of a column | `{"@type":"updateColumnPosition","fieldName": ["name"], "newPosition":"default"}` | `TableChange.updateColumnPosition(...)` |+| Supported modification | JSON | Java |+|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|+| Rename table | `{"@type":"rename","newName":"table_renamed"}` | `TableChange.rename("table_renamed")` |+| Update comment | `{"@type":"updateComment","newComment":"new_comment"}` | `TableChange.updateComment("new_comment")` |+| Set a table property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `TableChange.setProperty("key1", "value1")` |+| Remove a table property | `{"@type":"removeProperty","property":"key1"}` | `TableChange.removeProperty("key1")` |+| Add a column | `{"@type":"addColumn","fieldName":["position"],"type":"varchar(20)","comment":"Position of user","position":"FIRST","nullable": true, "autoIncrement": false, "defaultValue" : {"type": "literal", "dataType": "varchar(20)", "value": "Default Position"}}` | `TableChange.addColumn(...)` |+| Delete a column | `{"@type":"deleteColumn","fieldName": ["name"], "ifExists": true}` | `TableChange.deleteColumn(...)` |+| Rename a column | `{"@type":"renameColumn","oldFieldName":["name_old"], "newFieldName":"name_new"}` | `TableChange.renameColumn(...)` |+| Update the column comment | `{"@type":"updateColumnComment", "fieldName": ["name"], "newComment": "new comment"}` | `TableChange.updateColumnCommment(...)` |+| Update the type of a column | `{"@type":"updateColumnType","fieldName": ["name"], "newType":"varchar(100)"}` | `TableChange.updateColumnType(...)` |+| Update the nullability of a column | `{"@type":"updateColumnNullability","fieldName": ["name"],"nullable":true}` | `TableChange.updateColumnNullability(...)` |+| Update the position of a column | `{"@type":"updateColumnPosition","fieldName": ["name"], "newPosition":"default"}` | `TableChange.updateColumnPosition(...)` |+| Update the default value of a column | `{"@type":"updateColumnDefaultValue","fieldName": ["name"], "newDefaultValue":{"type":"literal","dataType":"varchar(100)","value":"new default value}}` | `TableChange.updateColumnDefaultValue(...)` |### Drop a tablediff --git a/docs/open-api/tables.yaml b/docs/open-api/tables.yamlindex 4e2303a02c..abbbfbd12d 100644--- a/docs/open-api/tables.yaml+++ b/docs/open-api/tables.yaml@@ -377,6 +377,7 @@ components:- $ref: "#/components/schemas/UpdateTableColumnCommentRequest"- $ref: "#/components/schemas/UpdateTableColumnPositionRequest"- $ref: "#/components/schemas/UpdateTableColumnNullabilityRequest"+ - $ref: "#/components/schemas/UpdateTableColumnDefaultValueRequest"- $ref: "#/components/schemas/DeleteTableColumnRequest"discriminator:propertyName: "@type"@@ -391,6 +392,7 @@ components:updateColumnComment: "#/components/schemas/UpdateTableColumnCommentRequest"updateColumnPosition: "#/components/schemas/UpdateTableColumnPositionRequest"updateColumnNullability: "#/components/schemas/UpdateTableColumnNullabilityRequest"+ updateColumnDefaultValue: "#/components/schemas/UpdateTableColumnDefaultValueRequest"deleteColumn: "#/components/schemas/DeleteTableColumnRequest"RenameTableRequest:@@ -642,6 +644,29 @@ components:"nullable": true}+ UpdateTableColumnDefaultValueRequest:+ type: object+ required:+ - "@type"+ - fieldName+ - newDefaultValue+ properties:+ "@type":+ type: string+ enum:+ - "updateColumnDefaultValue"+ fieldName:+ $ref: "#/components/schemas/FieldName"+ description: The name of the column to update+ newDefaultValue:+ $ref: "#/components/schemas/ColumnDefaultValue"+ description: The new default value of the column+ example: {+ "@type": "updateColumnDefaultValue",+ "fieldName": [ "existing_column" ],+ "newDefaultValue": { "type": "literal", "dataType": "varchar(100)", "value": "new default value" }+ }+DeleteTableColumnRequest:type: objectrequired: