This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new e26e6b5a4 [core] new column exception shows the specific column name 
(#2746)
e26e6b5a4 is described below

commit e26e6b5a4f0563310f72cf919e3d18c69be364a2
Author: Kerwin <[email protected]>
AuthorDate: Sat Jan 20 23:13:27 2024 +0800

    [core] new column exception shows the specific column name (#2746)
---
 docs/content/program-api/java-api.md                                 | 2 +-
 .../src/main/java/org/apache/paimon/schema/SchemaManager.java        | 4 +++-
 .../src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java   | 5 ++++-
 .../org/apache/paimon/flink/action/cdc/CdcActionCommonUtils.java     | 5 +++--
 .../paimon/flink/action/cdc/mysql/MySqlSyncTableActionITCase.java    | 2 +-
 .../java/org/apache/paimon/spark/SparkSchemaEvolutionITCase.java     | 2 +-
 6 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/docs/content/program-api/java-api.md 
b/docs/content/program-api/java-api.md
index 275d84625..9a811dcdf 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 5300084d0..07dda6196 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 class SchemaManager implements Serializable {
                     }
                     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 0a92024fb..10a57ecb8 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 class SchemaEvolutionTest {
                                                         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 d4a02ad54..c0413b31f 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 class CdcActionCommonUtils {
             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 af5f02db9..d7e14446a 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 class MySqlSyncTableActionITCase extends 
MySqlActionITCaseBase {
                 .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 d23d5d577..ac8326eb6 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 class SparkSchemaEvolutionITCase extends 
SparkReadTestBase {
                 .satisfies(
                         anyCauseMatches(
                                 IllegalArgumentException.class,
-                                "ADD COLUMN cannot specify NOT NULL."));
+                                "Column d cannot specify NOT NULL in the 
default.testAddNotNullColumn table."));
     }
 
     @Test

Reply via email to