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


Change subject: IMPALA-15302: Export a datetime plus with a literal interval
......................................................................

IMPALA-15302: Export a datetime plus with a literal interval

Calcite spells a date plus a literal interval as a multiply of the unit
by the count, so d + interval 5 days arrives at the seam as
+(d, CHECKED_TIMES(5, INTERVAL '1' DAY)). Substrait has add:date_iday
and add:date_iyear, but no multiply that takes an interval, so the
multiply is what stops the export rather than the plus. A signature for
the plus alone does not help, because the multiply fails first.

Fold a constant interval multiply into the interval literal it works out
to, and map Impala's datetime plus onto add. The qualifier comes from
the interval operand, which keeps months on the year-month side and days
on the day-time one without this code deciding anything.

A count that is not a literal, as in d + n * interval 1 day, stays
refused. Folding adjusts a constant; it cannot remove the multiply, and
Substrait has no multiply taking an interval to fall back on.

The converter added by IMPALA-15300 already rewrites operands before
matching, so the folding goes there and it is renamed for what it now
does.

Testing, in a local cluster on Linux:
- SubstraitPlanExporterTest: 20 tests, 0 failures, 0 errors. One added
  test covers days and months on a date and on a timestamp, so that the
  variant the qualifier selects is pinned; the other pins the refusal
  for a count that is not a literal
- CalciteOptimizerTest and CalciteSubstraitCompatibilityTest, neither
  of which this patch touches: 11 and 4 tests, 0 failures
- Dropping the folding fails the added test, so it is not vacuous
- A probe over the TPC-DS queries carrying Calcite goldens reports 102
  of 110 with this patch and 101 without it. This closes the last query
  blocked by something on our side: of the eight left, four are the
  deliberate SINGLE_VALUE refusal and four wait on substrait-java#993
- git diff --check

Change-Id: Ic4d091776f79c27877016d8329a1d4449cdd6b7b
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, 113 insertions(+), 7 deletions(-)



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

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

Reply via email to