diff --git a/docs/content/program-api/java-api.md b/docs/content/program-api/java-api.md index 275d846258c0..9a811dcdf521 100644 --- a/docs/content/program-api/java-api.md +++ b/docs/content/program-api/java-api.md @@ -310,7 +310,7 @@ public class RenameTable { You can use the catalog to alter a table, but you need to pay attention to the following points. -- Add column cannot specify NOT NULL. +- Column %s cannot specify NOT NULL in the %s table. - Cannot update partition column type in the table. - Cannot change nullability of primary key. - If the type of the column is nested row type, update the column type is not supported. diff --git a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java index 5300084d053d..07dda61966a0 100644 --- a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java +++ b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java @@ -189,7 +189,9 @@ public TableSchema commitChanges(List changes) } Preconditions.checkArgument( addColumn.dataType().isNullable(), - "ADD COLUMN cannot specify NOT NULL."); + "Column %s cannot specify NOT NULL in the %s table.", + addColumn.fieldName(), + fromPath(tableRoot.toString(), true).getFullName()); int id = highestFieldId.incrementAndGet(); DataType dataType = ReassignFieldId.reassign(addColumn.dataType(), highestFieldId); diff --git a/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java b/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java index 0a92024fbc39..10a57ecb80b5 100644 --- a/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java @@ -264,7 +264,10 @@ public void testAddField() throws Exception { null, null)))) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("ADD COLUMN cannot specify NOT NULL."); + .hasMessage( + String.format( + "Column %s cannot specify NOT NULL in the %s table.", + "f4", identifier.getFullName())); } @Test diff --git a/paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/CdcActionCommonUtils.java b/paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/CdcActionCommonUtils.java index d4a02ad54f2b..c0413b31f112 100644 --- a/paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/CdcActionCommonUtils.java +++ b/paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/CdcActionCommonUtils.java @@ -221,8 +221,9 @@ public static Schema buildPaimonSchema( for (String key : specifiedPrimaryKeys) { checkArgument( sourceColumns.contains(key), - "Specified primary key '%s' does not exist in source tables or computed columns.", - key); + "Specified primary key '%s' does not exist in source tables or computed columns %s.", + key, + sourceColumns); } builder.primaryKey(listCaseConvert(specifiedPrimaryKeys, caseSensitive)); } else if (!sourceSchema.primaryKeys().isEmpty()) { diff --git a/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncTableActionITCase.java b/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncTableActionITCase.java index af5f02db9120..d7e14446ac20 100644 --- a/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncTableActionITCase.java +++ b/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncTableActionITCase.java @@ -667,7 +667,7 @@ public void testInvalidPrimaryKey() { .satisfies( anyCauseMatches( IllegalArgumentException.class, - "Specified primary key 'pk' does not exist in source tables or computed columns.")); + "Specified primary key 'pk' does not exist in source tables or computed columns [pt, _id, v1].")); } @Test diff --git a/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkSchemaEvolutionITCase.java b/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkSchemaEvolutionITCase.java index d23d5d577656..ac8326eb65a4 100644 --- a/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkSchemaEvolutionITCase.java +++ b/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkSchemaEvolutionITCase.java @@ -101,7 +101,7 @@ public void testAddNotNullColumn() { .satisfies( anyCauseMatches( IllegalArgumentException.class, - "ADD COLUMN cannot specify NOT NULL.")); + "Column d cannot specify NOT NULL in the default.testAddNotNullColumn table.")); } @Test