deniskuzZ commented on code in PR #6218:
URL: https://github.com/apache/hive/pull/6218#discussion_r2594033645


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/BaseHiveIcebergMetaHook.java:
##########
@@ -202,6 +203,42 @@ public void preCreateTable(CreateTableRequest request) {
     // Remove hive primary key columns from table request, as iceberg doesn't 
support hive primary key.
     request.setPrimaryKeys(null);
     setSortOrder(hmsTable, schema, catalogProperties);
+    setWriteMetadataCleanupProperties(hmsTable.getParameters());
+  }
+
+  private void setWriteMetadataCleanupProperties(Map<String, String> 
hmsParams) {
+    setWriteMetadataCleanupProperty(hmsParams, 
TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED,
+        TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED,
+        
Boolean.toString(HIVE_ICEBERG_METADATA_DELETE_AFTER_COMMIT_ENABLED_DEFAULT));
+
+    setWriteMetadataCleanupProperty(hmsParams, 
TableProperties.METADATA_PREVIOUS_VERSIONS_MAX,
+        TableProperties.METADATA_PREVIOUS_VERSIONS_MAX,
+        
Integer.toString(TableProperties.METADATA_PREVIOUS_VERSIONS_MAX_DEFAULT));
+  }
+
+  /*
+   * Sets a write metadata cleanup configuration property for a table.
+   * If the table property exists in HMS parameters, it has precedence.
+   * If the table property is missing in HMS parameters, the method will use 
the value from the session,
+   * only if the write metadata cleanup is enabled. The resolved value is 
stored in `catalogProperties`.
+   */
+  private void setWriteMetadataCleanupProperty(Map<String, String> hmsParams, 
String key, String confKey,
+      String defaultValue) {
+
+    // If table property exists — always use it
+    if (hmsParams.containsKey(key)) {
+      catalogProperties.put(key, hmsParams.get(key));
+      return;
+    }
+
+    boolean isWriteMetadataCleanupEnabledInConf = conf.getBoolean(

Review Comment:
   should this be extracted and moved to parent method?
   ````
   if (isWriteMetadataCleanupEnabledInConf) {
     addCatalogProperty(
       TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED,
       TableProperties.METADATA_PREVIOUS_VERSIONS_MAX_DEFAULT),
       hmsParams);
     
     addCatalogProperty(
       TableProperties.METADATA_PREVIOUS_VERSIONS_MAX,
       TableProperties.METADATA_PREVIOUS_VERSIONS_MAX_DEFAULT),
       hmsParams);
   }
   ````



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to