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


Change subject: IMPALA-15339: Plan REAL and binary literals
......................................................................

IMPALA-15339: Plan REAL and binary literals

  set planner=calcite;
  select cast(1.5 as real);   -- Unsupported RexLiteral: DOUBLE
  select x'616263';           -- Unsupported RexLiteral: BINARY

RexLiteralConverter has no case for REAL or for BINARY, so a plan
carrying either literal stops where the literal becomes an Impala
expression, with the type mapped both ways by ImpalaTypeConverter and
the row type already derived. The REAL one is ordinary Impala SQL: the
original planner answers 1.5.

Add both. Calcite's REAL is Impala's DOUBLE, which is how the type
converter already reads it. A binary literal is a ByteString, and
Impala's StringLiteral takes bytes and holds them as bytes when they are
not valid UTF-8.

The message named DOUBLE for a REAL literal because it printed the
literal's own type name rather than the type the switch is on, pointing
at a case that was there. Print the latter.

Behind the binary case is the double conversion IMPALA-15338 skips for a
timestamp. Calcite folds a projection of constants into a VALUES row, so
the literal reaches ImpalaValuesRel, which re-creates it from its text --
which bytes that are not text do not have. Skip that conversion for a
binary value on the same grounds: the literal already carries the
declared type, which is the only thing the round trip establishes.

Bytes that are not valid UTF-8 therefore go from a refusal to a value.
That direction is checked rather than assumed: the end-to-end case reads
them back as FF00FE with length 3, and EXPLAIN renders a plan holding
one.

Testing:
- New CalciteMissingLiteralTest, 5 tests: a binary literal plans in a
  projection and in a VALUES row; bytes that are not valid UTF-8 plan; a
  REAL literal plans in both places; the same value written as a cast
  still plans. Reverting the binary case fails three of them with
  "Unsupported RexLiteral: BINARY" and leaves the cast green; reverting
  REAL fails one, now naming REAL; reverting the skip fails only the
  non-UTF-8 one, with "non-utf8 string".
- New calcite.test case, executed through TestCalcitePlanner.
- calcite-planner module suite: no class changed its result.

Change-Id: I9dcf194fc0fa604bc570853b7853650f8d60a0dd
Assisted-by: claude-opus-5 (Claude Code)
---
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
A 
java/calcite-planner/src/test/java/org/apache/impala/calcite/service/CalciteMissingLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 138 insertions(+), 7 deletions(-)



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

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

Reply via email to