Zoltan Borok-Nagy has uploaded this change for review. ( http://gerrit.cloudera.org:8080/25062
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(), the ABI wrapper of LlvmCodeGen::AddFunctionToJit() and LoadFunction() 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 SlotRefReadVariantVal(), 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 and UNION ALL 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 M be/src/exprs/slot-ref.cc M be/src/exprs/slot-ref.h M be/src/runtime/fragment-state.cc 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 17 files changed, 607 insertions(+), 67 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/62/25062/1 -- To view, visit http://gerrit.cloudera.org:8080/25062 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I08c6a4e9a4b6759276da1340d91ac0606f8b1419 Gerrit-Change-Number: 25062 Gerrit-PatchSet: 1 Gerrit-Owner: Zoltan Borok-Nagy <[email protected]>
