Aleksandr Efimov has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/24743


Change subject: IMPALA-15298: Export Impala's IF as a Substrait IfThen
......................................................................

IMPALA-15298: Export Impala's IF as a Substrait IfThen

IMPALA-15297 mapped the Impala operators that stand in for functions
Substrait already has, which took the harness corpus from twenty of
twenty-four shapes to twenty-three. The one left is EXCEPT.

Substrait models a conditional as the IfThen expression rather than as
a function, so IF has no name for a signature to map to and needs a
call converter instead. Isthmus does the same for Calcite's CASE, which
is why a CASE in the query already exports while an IF does not.

IF is not only what a user writes. ImpalaMinusToDistinctRule builds one
while rewriting EXCEPT, so a query that never mentions IF still ends up
carrying one, and that is what stops the EXCEPT shape.

Isthmus takes converters for functions through its builder but
assembles the call converters in a method, so this goes in by extending
ConverterProvider and overriding getCallConverters. The converter is
put ahead of the scalar one, which is last and would otherwise fail the
call before this one sees it.

The null handling needs no special care: Impala returns the else branch
when the condition is null, and a null condition is not true, so
Substrait takes the else clause too.

With this the whole corpus exports.

Testing, in a local cluster on Linux, the three classes in one run:
- SubstraitPlanExporterTest: 14 tests, 0 failures, 0 errors. The two
  added ones check that a written IF comes out as an IF_THEN
  expression rather than a call, and that the EXCEPT shape exports
- CalciteOptimizerTest and CalciteSubstraitCompatibilityTest, neither
  of which this patch touches: 11 and 4 tests, 0 failures
- Withholding the converter fails both added tests, so neither is
  vacuous
- A probe over the harness corpus reports 24 of 24 with this patch and
  23 of 24 without it
- git diff --check

Change-Id: I631f81cdfc002d3918d05ea936bcfbfcd54da03e
Assisted-by: Claude Opus 5 (Anthropic)
---
M 
java/calcite-planner/src/test/java/org/apache/impala/calcite/service/SubstraitOperatorMappings.java
M 
java/calcite-planner/src/test/java/org/apache/impala/calcite/service/SubstraitPlanExporterTest.java
2 files changed, 91 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/43/24743/1
--
To view, visit http://gerrit.cloudera.org:8080/24743
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I631f81cdfc002d3918d05ea936bcfbfcd54da03e
Gerrit-Change-Number: 24743
Gerrit-PatchSet: 1
Gerrit-Owner: Aleksandr Efimov <[email protected]>

Reply via email to