mchades commented on code in PR #13771:
URL: https://github.com/apache/gravitino/pull/13771#discussion_r4248005625


##########
core/src/main/java/org/apache/gravitino/catalog/TableOperationDispatcher.java:
##########
@@ -582,11 +592,12 @@ private EntityCombinedTable importTable(NameIdentifier 
identifier) {
             .withAuditInfo(audit)
             .build();
     try {
-      // Overwrite only with the id stored in the catalog: it identifies the 
table, so a row under
-      // the same name with another id is stale and gets replaced. A generated 
id identifies
-      // nothing, so a row that appeared meanwhile, e.g. from a concurrent 
import on another node,
-      // must win. The plain insert then conflicts, and loadTable reloads that 
row.
-      store.put(tableEntity, stringId != null);
+      // Never overwrite imported table metadata. In particular, an overwrite 
by stable ID can
+      // silently change schema or catalog ownership and make existing 
privileges refer to the
+      // wrong path.
+      store.put(tableEntity, false);

Review Comment:
   **[P1] Normalize Hive-backed Iceberg aliases before rejecting imports**
   
   With the Hive backend of `lakehouse-iceberg`, loading a table through an 
uppercase spelling after creating it with a lowercase name resolves to the same 
Hive table and `gravitino.identifier`. `IcebergCatalogCapability` still uses 
the default case-sensitive rules, so both the initial lookup and the conflict 
reload use the uppercase path. This create-only write then conflicts with the 
existing ID, and loading the table fails with a manual-reconciliation error.
   
   The `INSERT INTO %S` in `SparkCommonIT.testAlterTableReplaceColumns` already 
exercises this scenario: the [historical CI 
log](https://github.com/apache/gravitino/actions/runs/38220570510/job/114730549951)
 shows the failure while loading `TEST_REPLACE_COLUMNS_TABLE`. The new 
`SparkIcebergCatalogHiveBackendIT` override changes that normal write to an 
expected failure. Normalize identifiers according to the Hive backend before 
rejecting the import, and retain the original success assertions so ordinary 
mixed-case SQL continues to work.



-- 
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]

Reply via email to