You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/12/12 12:57:32 UTC

[GitHub] [iceberg] pvary commented on a change in pull request #1917: Hive: Convert the CREATE TABLE ... PARTITIONED BY to Iceberg identity partitions

pvary commented on a change in pull request #1917:
URL: https://github.com/apache/iceberg/pull/1917#discussion_r541571405



##########
File path: mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
##########
@@ -197,20 +205,32 @@ private static Schema schema(Properties properties, org.apache.hadoop.hive.metas
     if (properties.getProperty(InputFormatConfig.TABLE_SCHEMA) != null) {
       return SchemaParser.fromJson(properties.getProperty(InputFormatConfig.TABLE_SCHEMA));
     } else {
-      return HiveSchemaUtil.convert(hmsTable.getSd().getCols());
+      if (hmsTable.isSetPartitionKeys() && hmsTable.getPartitionKeys().size() != 0) {

Review comment:
       Done

##########
File path: mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
##########
@@ -197,20 +205,32 @@ private static Schema schema(Properties properties, org.apache.hadoop.hive.metas
     if (properties.getProperty(InputFormatConfig.TABLE_SCHEMA) != null) {
       return SchemaParser.fromJson(properties.getProperty(InputFormatConfig.TABLE_SCHEMA));
     } else {
-      return HiveSchemaUtil.convert(hmsTable.getSd().getCols());
+      if (hmsTable.isSetPartitionKeys() && hmsTable.getPartitionKeys().size() != 0) {
+        // Add partitioning columns to the original column list before creating the Iceberg Schema
+        List<FieldSchema> cols = new ArrayList<>(hmsTable.getSd().getCols());
+        cols.addAll(hmsTable.getPartitionKeys());
+        return HiveSchemaUtil.convert(cols);
+      } else {
+        return HiveSchemaUtil.convert(hmsTable.getSd().getCols());
+      }
     }
   }
 
   private static PartitionSpec spec(Schema schema, Properties properties,
       org.apache.hadoop.hive.metastore.api.Table hmsTable) {
 
-    Preconditions.checkArgument(hmsTable.getPartitionKeys() == null || hmsTable.getPartitionKeys().isEmpty(),
-        "Partitioned Hive tables are currently not supported");
-
     if (properties.getProperty(InputFormatConfig.PARTITION_SPEC) != null) {
+      Preconditions.checkArgument(hmsTable.getPartitionKeys() == null || hmsTable.getPartitionKeys().isEmpty(),

Review comment:
       Done




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org