From 8232c1599a8801cfeb62cc0f2b959c2228f7c94d Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Tue, 10 Dec 2024 11:32:56 +0800 Subject: [PATCH] update --- .../org/apache/paimon/schema/SchemaManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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. */