dengzhhu653 commented on a change in pull request #992:
URL: https://github.com/apache/hive/pull/992#discussion_r413913032



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
##########
@@ -789,12 +791,25 @@ protected void validateUDF(ASTNode expr, boolean 
isFunction, TypeCheckCtx ctx, F
 
         LogHelper console = new LogHelper(LOG);
 
+        Set<PrimitiveObjectInspector.PrimitiveCategory> unsafeConventionTyps = 
Sets.newHashSet(
+            PrimitiveObjectInspector.PrimitiveCategory.STRING,
+            PrimitiveObjectInspector.PrimitiveCategory.VARCHAR,
+            PrimitiveObjectInspector.PrimitiveCategory.CHAR);
         // For now, if a bigint is going to be cast to a double throw an error 
or warning
-        if ((oiTypeInfo0.equals(TypeInfoFactory.stringTypeInfo) && 
oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
-            (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && 
oiTypeInfo1.equals(TypeInfoFactory.stringTypeInfo))) {
+        if ((oiTypeInfo0 instanceof PrimitiveTypeInfo &&
+            
unsafeConventionTyps.contains(((PrimitiveTypeInfo)oiTypeInfo0).getPrimitiveCategory())
 &&
+            oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) || (oiTypeInfo1 
instanceof PrimitiveTypeInfo &&
+            
unsafeConventionTyps.contains(((PrimitiveTypeInfo)oiTypeInfo1).getPrimitiveCategory())
 &&
+            oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo))) {
           String error = StrictChecks.checkTypeSafety(conf);
-          if (error != null) throw new UDFArgumentException(error);
-          console.printError("WARNING: Comparing a bigint and a string may 
result in a loss of precision.");
+          if (error != null) {
+            throw new UDFArgumentException(error);
+          }
+          String type = oiTypeInfo0.getTypeName();
+          if (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo)) {
+            type = oiTypeInfo1.getTypeName();
+          }
+          console.printError("WARNING: Comparing a bigint and a " + type + " 
may result in a loss of precision.");

Review comment:
       yes, the variable can be removed by this way, thank you.




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