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:
[email protected]



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

Reply via email to