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


##########
iceberg/iceberg-catalog/pom.xml:
##########
@@ -69,7 +69,6 @@
     <dependency>
       <groupId>org.apache.hive</groupId>
       <artifactId>hive-exec</artifactId>
-      <scope>test</scope>

Review Comment:
   shouldn't the hook be executed before the actual catalog call?
   
   ````
   Subject: [PATCH] refactor
   ---
   Index: 
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/client/HiveRESTCatalogClient.java
   IDEA additional info:
   Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
   <+>UTF-8
   ===================================================================
   diff --git 
a/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/client/HiveRESTCatalogClient.java
 
b/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/client/HiveRESTCatalogClient.java
   --- 
a/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/client/HiveRESTCatalogClient.java
        (revision 17ddd7ae619c61eb9dad21f90914476f9c670800)
   +++ 
b/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/client/HiveRESTCatalogClient.java
        (date 1754988707063)
   @@ -264,8 +264,9 @@
        }
        Properties catalogProperties = 
HMSTablePropertyHelper.getCatalogProperties(table);
        Schema schema = HiveSchemaUtil.convert(cols, true);
   +    org.apache.iceberg.PartitionSpec partitionSpec =
   +        
HMSTablePropertyHelper.getPartitionSpec(request.getEnvContext().getProperties(),
 schema);
        SortOrder sortOrder = 
HMSTablePropertyHelper.getSortOrder(catalogProperties, schema);
   -    org.apache.iceberg.PartitionSpec partitionSpec = 
HMSTablePropertyHelper.createPartitionSpec(this.conf, schema);
    
        restCatalog.buildTable(TableIdentifier.of(table.getDbName(), 
table.getTableName()), schema)
            
.withPartitionSpec(partitionSpec).withLocation(catalogProperties.getProperty(LOCATION)).withSortOrder(sortOrder)
   Index: 
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
   IDEA additional info:
   Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
   <+>UTF-8
   ===================================================================
   diff --git 
a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
 
b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
   --- 
a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
      (revision 17ddd7ae619c61eb9dad21f90914476f9c670800)
   +++ 
b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
      (date 1754989182493)
   @@ -276,7 +276,9 @@
        }
    
        catalogProperties.put(InputFormatConfig.TABLE_SCHEMA, 
SchemaParser.toJson(schema));
   -    catalogProperties.put(InputFormatConfig.PARTITION_SPEC, 
PartitionSpecParser.toJson(spec));
   +    String specString = PartitionSpecParser.toJson(spec);
   +    catalogProperties.put(InputFormatConfig.PARTITION_SPEC, specString);
   +    
request.getEnvContext().putToProperties(TableProperties.DEFAULT_PARTITION_SPEC, 
specString);
        setCommonHmsTablePropertiesForIceberg(hmsTable);
    
        if 
(hmsTable.getParameters().containsKey(BaseMetastoreTableOperations.METADATA_LOCATION_PROP))
 {
   Index: data/conf/iceberg/llap/hive-site.xml
   IDEA additional info:
   Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
   <+>UTF-8
   ===================================================================
   diff --git a/data/conf/iceberg/llap/hive-site.xml 
b/data/conf/iceberg/llap/hive-site.xml
   --- a/data/conf/iceberg/llap/hive-site.xml   (revision 
17ddd7ae619c61eb9dad21f90914476f9c670800)
   +++ b/data/conf/iceberg/llap/hive-site.xml   (date 1754985494550)
   @@ -398,7 +398,7 @@
            <value>2</value>
        </property>
        
   -    <!-- -- Iceberg REST catalog specific properties -->
   +    <!-- Iceberg REST catalog specific properties -->
        <property>
            <name>iceberg.catalog.type</name>
            <value>rest</value>
   Index: 
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
   IDEA additional info:
   Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
   <+>UTF-8
   ===================================================================
   diff --git 
a/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
 
b/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
   --- 
a/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
      (revision 17ddd7ae619c61eb9dad21f90914476f9c670800)
   +++ 
b/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
      (date 1754988604100)
   @@ -303,6 +303,12 @@
        }
      }
    
   +  public static PartitionSpec getPartitionSpec(Map<String, String> props, 
Schema schema) {
   +    return 
Optional.ofNullable(props.get(TableProperties.DEFAULT_PARTITION_SPEC))
   +        .map(spec -> PartitionSpecParser.fromJson(schema, spec))
   +        .orElse(PartitionSpec.unpartitioned());
   +  }
   +
      @VisibleForTesting
      static void setSortOrder(TableMetadata metadata, Map<String, String> 
parameters, long maxHiveTablePropertySize) {
        parameters.remove(TableProperties.DEFAULT_SORT_ORDER);
   
   ````



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to