Hello Arnab Karmakar, Balazs Hevele, Peter Rozsa, Csaba Ringhofer, Impala 
Public Jenkins,

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/25062

to look at the new patch set (#3).

Change subject: IMPALA-15141 (part 2): Codegen expressions that involve VARIANT
......................................................................

IMPALA-15141 (part 2): Codegen expressions that involve VARIANT

Expressions that produce or consume a VARIANT value were always
interpreted, e.g. a scan lost the codegen of all of its conjuncts if
one of them contained variant_get(). This patch adds codegen support
for such expressions.

A VariantVal is opaque in codegen: generated code only passes it
around and checks 'is_null', its fields are only accessed by
cross-compiled functions.
* CodegenAnyVal handles TYPE_VARIANT. Similarly to DecimalVal,
  VariantVal (40 bytes) is never lowered: cross-compiled and native
  functions return it via an output argument, while generated
  functions return it by value. CodegenAnyVal::CreateCall() and the
  ABI wrapper of LlvmCodeGen::AddFunctionToJit() were generalized
  accordingly.
* variant-functions-ir.cc was missing from impala-ir.cc, so the
  VARIANT builtins were not available in the IR module.
* SlotRef reads VARIANT slots via the new cross-compiled
  SlotRefIr::ReadVariantVal(), which gets the layout of the slot as
  constants. The interpreted path calls the same function. This
  replaces the unused STRUCT-like code path in CodegenReadSlot() that
  relied on child evaluators, which do not exist for VARIANT.
* ScalarExpr::ShouldCodegen() only prevents expressions that return
  VARIANT from being codegen entry points, because native code only
  consumes VARIANT values on interpreted paths. They are codegen'd as
  children of other expressions. The transitive InvolvesVariantType()
  check and the fallback in GetCodegendComputeFn() were removed.

Materializing VARIANT slots is still not codegen'd, i.e. TOP-N, UNION
ALL and CTE consumer nodes fall back if their output tuple has a VARIANT
slot.

Note that the codegen'd AND/OR evaluate both of their operands, unlike
the interpreted ones. Therefore a strict variant_get() in an AND/OR
can raise an error for rows that are filtered out by the other
operand. This is the same for other functions that can fail, e.g.
DECIMAL arithmetic. try_variant_get(), CASE or if() can be used
instead. Filed IMPALA-15517 to track this separately.

Testing:
* added backend tests for the layout, the NULL handling and the
  calling conventions of VariantVal
* added e2e tests that check the codegen status of the operators in
  the runtime profile
* added e2e tests for VARIANT values of nullable tuples, NULL
  VARIANT values, and UNION ALL of VARIANT values returned by
  functions

Change-Id: I08c6a4e9a4b6759276da1340d91ac0606f8b1419
Assisted-by: Claude Fable 5.1 (Claude Code)
---
M be/src/codegen/codegen-anyval.cc
M be/src/codegen/codegen-anyval.h
M be/src/codegen/gen_ir_descriptions.py
M be/src/codegen/impala-ir.cc
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/exprs/CMakeLists.txt
M be/src/exprs/scalar-expr-ir.cc
M be/src/exprs/scalar-expr.cc
M be/src/exprs/scalar-expr.h
A be/src/exprs/slot-ref-ir.cc
A be/src/exprs/slot-ref-ir.h
M be/src/exprs/slot-ref.cc
M be/src/exprs/slot-ref.h
M be/src/runtime/fragment-state.cc
M be/src/runtime/fragment-state.h
A 
testdata/workloads/functional-query/queries/QueryTest/iceberg-v3-variant-codegen.test
M 
testdata/workloads/functional-query/queries/QueryTest/iceberg-v3-variant-get.test
M tests/query_test/test_iceberg.py
19 files changed, 653 insertions(+), 65 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/62/25062/3
--
To view, visit https://gerrit.cloudera.org/25062
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I08c6a4e9a4b6759276da1340d91ac0606f8b1419
Gerrit-Change-Number: 25062
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <[email protected]>
Gerrit-Reviewer: Arnab Karmakar <[email protected]>
Gerrit-Reviewer: Balazs Hevele <[email protected]>
Gerrit-Reviewer: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Peter Rozsa <[email protected]>

Reply via email to