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 325e0c392d12..9edbe901b6fa 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 @@ -262,7 +262,9 @@ private void checkSchemaForExternalTable(Schema existsSchema, Schema newSchema) Map newOptions = newSchema.options(); newOptions.forEach( (key, value) -> { + // ignore `owner` and `path` if (!key.equals(Catalog.OWNER_PROP) + && !key.equals(CoreOptions.PATH.key()) && (!existsOptions.containsKey(key) || !existsOptions.get(key).equals(value))) { throw new RuntimeException( diff --git a/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DDLWithHiveCatalogTestBase.scala b/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DDLWithHiveCatalogTestBase.scala index 5311c586a59c..ee8e9dda7e2c 100644 --- a/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DDLWithHiveCatalogTestBase.scala +++ b/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DDLWithHiveCatalogTestBase.scala @@ -553,6 +553,27 @@ abstract class DDLWithHiveCatalogTestBase extends PaimonHiveTestBase { } } + test("Paimon DDL with hive catalog: create external based on managed table location") { + Seq(sparkCatalogName, paimonHiveCatalogName).foreach { + catalogName => + spark.sql(s"USE $catalogName") + withDatabase("paimon_db") { + spark.sql(s"CREATE DATABASE IF NOT EXISTS paimon_db") + spark.sql(s"USE paimon_db") + withTable("external_tbl", "managed_tbl") { + spark.sql(s"CREATE TABLE managed_tbl (id INT) USING paimon") + spark.sql("INSERT INTO managed_tbl VALUES (1)") + checkAnswer(spark.sql("SELECT * FROM managed_tbl"), Row(1)) + + val tablePath = loadTable("paimon_db", "managed_tbl").location().toString + spark.sql(s"CREATE TABLE external_tbl (id INT) USING paimon LOCATION '$tablePath'") + checkAnswer(spark.sql("SELECT * FROM external_tbl"), Row(1)) + assert(loadTable("paimon_db", "external_tbl").location().toString.equals(tablePath)) + } + } + } + } + test("Paimon DDL with hive catalog: case sensitive") { Seq(sparkCatalogName, paimonHiveCatalogName).foreach { catalogName =>