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 6b3a83c8ce39..2139dca4a990 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 @@ -212,14 +212,16 @@ public TableSchema createTable(Schema schema, boolean externalTable) throws Exce while (true) { Optional latest = latest(); if (latest.isPresent()) { - if (externalTable && checkSchemaForExternalTable(latest.get(), schema)) { - return latest.get(); + TableSchema latestSchema = latest.get(); + if (externalTable) { + checkSchemaForExternalTable(latestSchema, schema); + return latestSchema; } else { throw new IllegalStateException( - "Schema in filesystem exists, creation is not allowed."); + "Schema in filesystem exists, creation is not allowed."); } } - + List fields = schema.fields(); List partitionKeys = schema.partitionKeys(); List primaryKeys = schema.primaryKeys(); @@ -246,7 +248,7 @@ public TableSchema createTable(Schema schema, boolean externalTable) throws Exce } } - private boolean checkSchemaForExternalTable(TableSchema existsSchema, Schema newSchema) { + private void checkSchemaForExternalTable(TableSchema existsSchema, Schema newSchema) { // When creating an external table, if the table already exists in the location, we can // choose not to specify the fields. if (newSchema.fields().isEmpty() @@ -276,7 +278,6 @@ private boolean checkSchemaForExternalTable(TableSchema existsSchema, Schema new + ", exists schema: " + existsSchema); } - return true; } /** Update {@link SchemaChange}s. */