nickdelnano commented on code in PR #7423:
URL: https://github.com/apache/paimon/pull/7423#discussion_r2933660521
##########
paimon-core/src/main/java/org/apache/paimon/jdbc/JdbcCatalog.java:
##########
@@ -486,14 +554,58 @@ public void repairTable(Identifier identifier) throws
TableNotExistException {
LOG.error("Failed to repair table: {}", identifier);
}
}
- // If table exists in both file system and JDBC catalog, nothing to
repair
+ if (syncTableProperties()) {
+ // Delete existing properties and reinsert from filesystem schema
+ execute(
+ connections,
+ JdbcUtils.DELETE_ALL_TABLE_PROPERTIES_SQL,
+ catalogKey,
+ identifier.getDatabaseName(),
+ identifier.getTableName());
+ JdbcUtils.insertTableProperties(
+ connections,
+ catalogKey,
+ identifier.getDatabaseName(),
+ identifier.getTableName(),
+ collectTableProperties(tableSchema));
+ }
}
@Override
public void close() throws Exception {
connections.close();
}
+ private boolean syncTableProperties() {
+ return options.get(CatalogOptions.SYNC_ALL_PROPERTIES);
+ }
+
+ private Map<String, String> convertToPropertiesTableKey(TableSchema
tableSchema) {
+ Map<String, String> properties = new HashMap<>();
+ if (!tableSchema.primaryKeys().isEmpty()) {
+ properties.put(
+ CoreOptions.PRIMARY_KEY.key(),
+ String.join(",", tableSchema.primaryKeys()));
+ }
+ if (!tableSchema.partitionKeys().isEmpty()) {
+ properties.put(
+ CoreOptions.PARTITION.key(),
+ String.join(",", tableSchema.partitionKeys()));
+ }
+ if (!tableSchema.bucketKeys().isEmpty()) {
+ properties.put(
+ CoreOptions.BUCKET_KEY.key(),
+ String.join(",", tableSchema.bucketKeys()));
+ }
+ return properties;
+ }
Review Comment:
https://github.com/apache/paimon/blob/master/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java#L1682-L1698
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]