Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy committed Dec 10, 2024
1 parent 9767d5b commit 8232c15
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ public TableSchema createTable(Schema schema, boolean externalTable) throws Exce
while (true) {
Optional<TableSchema> 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<DataField> fields = schema.fields();
List<String> partitionKeys = schema.partitionKeys();
List<String> primaryKeys = schema.primaryKeys();
Expand All @@ -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()
Expand Down Expand Up @@ -276,7 +278,6 @@ private boolean checkSchemaForExternalTable(TableSchema existsSchema, Schema new
+ ", exists schema: "
+ existsSchema);
}
return true;
}

/** Update {@link SchemaChange}s. */
Expand Down

0 comments on commit 8232c15

Please sign in to comment.