jcamachor commented on a change in pull request #1031:
URL: https://github.com/apache/hive/pull/1031#discussion_r432118212



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/DataSketchesFunctions.java
##########
@@ -235,12 +232,21 @@ public String getFunctionName() {
         return Optional.empty();
       } else {
         JavaTypeFactoryImpl typeFactory = new JavaTypeFactoryImpl(new 
HiveTypeSystemImpl());
+        Type type = returnType;
+        if (type instanceof ParameterizedType) {
+          ParameterizedType parameterizedType = (ParameterizedType) type;
+          if (parameterizedType.getRawType() == List.class) {
+          final RelDataType componentRelType = 
typeFactory.createType(parameterizedType.getActualTypeArguments()[0]);
+          return Optional
+              
.of(typeFactory.createArrayType(typeFactory.createTypeWithNullability(componentRelType,
 true), -1));
+          }
+        }
         return Optional.of(typeFactory.createType(returnType));
       }

Review comment:
       I have a general comment about the approach we are taking in these 
methods to infer the return type.
   I think we should rethink inferring the return type from the Java returned 
object from 'evaluate' and we could possibly take a step back.
   One option could be create the necessary `SqlReturnTypeInference` strategies 
to be able to return the correct type depending on the functions. If the 
inference is simple, we could hardcode some of those return types. This is the 
general approach taken by Calcite functions. I think that will help simplifying 
this code a lot.
   What do you think? Do you have any other ideas?




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