[ 
https://issues.apache.org/jira/browse/HIVE-11462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14659427#comment-14659427
 ] 

Hari Sankar Sivarama Subramaniyan commented on HIVE-11462:
----------------------------------------------------------

{code}
    boolean constantStruct = true;
    Object[] constantValues = new Object[arguments.length];
    for (int i = 0; i < arguments.length; i++) {
      ObjectInspector oi = arguments[i];
      constantStruct &= (oi instanceof ConstantObjectInspector);
      if (constantStruct) {
        constantValues[i] = 
((ConstantObjectInspector)oi).getWritableConstantValue();
      }
    }
{code}

[~gopalv] my earlier point (1) was that we don't use constantValues to 
instantiate the constant struct object inspector via 
ObjectInspectorFactory.getStandardConstantStructObjectInspector(); we use ret 
instead. If we are going to evaluate the struct irrespective of it being 
constant to keep things as-is, we will not require constantValues. Thus we can 
possibly replace the above code with something similar to the below one:
{code}
    boolean constantStruct = true;
    for (int i = 0; i < arguments.length; i++) {
      if (!(arguments[i] instanceof ConstantObjectInspector)) {
        constantStruct = false;
        break;
      }
    }
{code}

The change otherwise looks fine.

Thanks
Hari

> GenericUDFStruct should constant fold at compile time
> -----------------------------------------------------
>
>                 Key: HIVE-11462
>                 URL: https://issues.apache.org/jira/browse/HIVE-11462
>             Project: Hive
>          Issue Type: Bug
>          Components: UDF
>    Affects Versions: 2.0.0
>            Reporter: Gopal V
>         Attachments: HIVE-11462.1.patch, HIVE-11462.WIP.patch
>
>
> HIVE-11428 introduces a constant Struct Object, which is available for the 
> runtime operators to assume as a constant parameter.
> This operator isn't constant folded during compilation since the UDF returns 
> a complex type, which is logged as warning by the constant propogation layer.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to