Zoltán Borók-Nagy created IMPALA-15830:
------------------------------------------

             Summary: Codegen VARIANT-typed expressions that native code 
evaluates directly
                 Key: IMPALA-15830
                 URL: https://issues.apache.org/jira/browse/IMPALA-15830
             Project: IMPALA
          Issue Type: Sub-task
            Reporter: Zoltán Borók-Nagy


{{ScalarExpr::ShouldCodegen()}} excludes every expression whose type is 
VARIANT. Such an expression is codegen'd only as the child of a codegen'd 
expression. When native code evaluates it directly, for example a VARIANT in 
the SELECT list of the query result or a sort that materializes one, it and its 
whole subtree run interpreted, including the parts that do not return VARIANT. 
In
{code:sql}
SELECT variant_get(v, concat('$.', name)) FROM t;
{code}
{{concat()}} is evaluated interpreted for every row.

IMPALA-15141 excluded these expressions because native code only consumed 
VARIANT values on interpreted paths, and because an entry point that fails to 
codegen fails the query. The pieces for codegen'd entry points are in place 
now: {{ScalarExpr::GetVariantVal()}} calls the JIT'd function when there is 
one, and {{AddFunctionToJit()}} wraps functions that return a {{VariantVal}} 
for native callers.

Drop the VARIANT check from {{ShouldCodegen()}}, after making sure that every 
expression kind that can return VARIANT codegens: slot references, the 
two-argument {{variant_get()}} and {{try_variant_get()}}, and NULL literals. 
The gain is small for the common {{SELECT v}} or {{variant_get(v, '$.a')}}, so 
this is a low-priority follow-up to IMPALA-15820. Testing should include an 
aarch64 run, because a missing wrapper for the {{VariantVal}} return value only 
breaks there.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to