Skip to content

Commit 83449d3

Browse files
committed
fix comments
1 parent a9ac488 commit 83449d3

File tree

3 files changed

+39
-197
lines changed

3 files changed

+39
-197
lines changed

fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/PaimonLakeCatalog.java

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.paimon.types.DataType;
4242
import org.apache.paimon.types.DataTypes;
4343

44-
import java.util.HashMap;
4544
import java.util.LinkedHashMap;
4645
import java.util.List;
4746
import java.util.Map;
@@ -170,8 +169,8 @@ private void alterTable(Identifier tablePath, List<SchemaChange> tableChanges)
170169
private void validatePaimonSchemaCapability(
171170
Identifier tablePath, Schema existingSchema, Schema newSchema) {
172171
// Adjust options for comparison
173-
Map<String, String> existingOptions = new HashMap<>(existingSchema.options());
174-
Map<String, String> newOptions = new HashMap<>(newSchema.options());
172+
Map<String, String> existingOptions = existingSchema.options();
173+
Map<String, String> newOptions = newSchema.options();
175174
// `path` will be set automatically by Paimon, so we need to remove it in existing options
176175
existingOptions.remove(CoreOptions.PATH.key());
177176
// when enable datalake with an existing table, `table.datalake.enabled` will be `false`
@@ -182,40 +181,14 @@ private void validatePaimonSchemaCapability(
182181
newOptions.remove(datalakeConfigKey);
183182
}
184183

185-
// Build schemas with adjusted options for comparison
186-
Schema adjustedExistingSchema = buildSchemaWithOptions(existingSchema, existingOptions);
187-
Schema adjustedNewSchema = buildSchemaWithOptions(newSchema, newOptions);
188-
189-
if (!adjustedExistingSchema.equals(adjustedNewSchema)) {
184+
if (!existingSchema.equals(newSchema)) {
190185
throw new TableAlreadyExistException(
191186
String.format(
192187
"The table %s already exists in Paimon catalog, but the table schema is not compatible. "
193188
+ "Existing schema: %s, new schema: %s. "
194189
+ "Please first drop the table in Paimon catalog or use a new table name.",
195-
tablePath.getEscapedFullName(),
196-
adjustedExistingSchema,
197-
adjustedNewSchema));
198-
}
199-
}
200-
201-
private Schema buildSchemaWithOptions(Schema schema, Map<String, String> options) {
202-
Schema.Builder builder = Schema.newBuilder();
203-
// Copy fields
204-
for (org.apache.paimon.types.DataField field : schema.fields()) {
205-
builder.column(field.name(), field.type(), field.description());
206-
}
207-
// Copy primary keys
208-
if (!schema.primaryKeys().isEmpty()) {
209-
builder.primaryKey(schema.primaryKeys());
210-
}
211-
// Copy partition keys
212-
if (!schema.partitionKeys().isEmpty()) {
213-
builder.partitionKeys(schema.partitionKeys());
190+
tablePath.getEscapedFullName(), existingSchema, newSchema));
214191
}
215-
// Set adjusted options
216-
builder.options(options);
217-
builder.comment(schema.comment());
218-
return builder.build();
219192
}
220193

221194
private void checkTableIsEmpty(Identifier tablePath, FileStoreTable table) {

0 commit comments

Comments
 (0)