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 2021/01/18 18:41:37 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #2054: Hive: Allow auto conversion of Hive types when the CREATE TABLE statement contains a not supported type

rdblue commented on a change in pull request #2054:
URL: https://github.com/apache/iceberg/pull/2054#discussion_r559744676



##########
File path: hive-metastore/src/main/java/org/apache/iceberg/hive/HiveSchemaConverter.java
##########
@@ -73,9 +79,14 @@ Type convertType(TypeInfo typeInfo) {
             return Types.BooleanType.get();
           case BYTE:
           case SHORT:
-            throw new IllegalArgumentException("Unsupported Hive type (" +
-                ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory() +
-                ") for Iceberg tables. Consider using INT/INTEGER type instead.");
+            if (autoConvert) {
+              LOG.debug("Using auto conversion from SHORT to INTEGER");
+              return Types.IntegerType.get();
+            } else {
+              throw new IllegalArgumentException("Unsupported Hive type (" +
+                  ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory() +
+                  ") for Iceberg tables. Consider using INT/INTEGER type instead.");
+            }

Review comment:
       You could probably make this a bit cleaner by using a `Precondition`:
   
   ```java
       Preconditions.check(autoConvert,
           "Unsupported Hive type: %s, use integer instead", ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory());
       return Types.IntegerType.get();
   ```
   
   That way, you'd get string formatting for free.




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