You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org> on 2026/09/08 10:33:23 UTC

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

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


Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................

IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

  set planner=calcite;
  values (timestamp '2024-01-01 00:02:03.456');

  ParseException: Syntax error in line 1:
  values (timestamp '2024-01-01 00:02:03.456')
          ^
  Encountered: TIMESTAMP

The parse error is the original planner's: only Calcite's parser accepts
this statement, and when the Calcite planner refuses it,
Frontend.getTExecRequestWithFallback passes it on as unsupported SQL.
That handoff is separate from the fallback_planner option and happens
with fallback_planner=none too, which is why the failure reads as a
syntax error rather than as a planner refusal.

What the Calcite planner refuses is the literal.
ImpalaValuesRel.getValuesExprs converts each literal of a VALUES row
twice: RexLiteralConverter builds a cast from the literal's text and has
the backend fold it, which is where the TimestampLiteral comes from, and
getLiteralExprWithType then re-creates that literal from its own text
through LiteralExpr.createFromStr, to give it the type the column
declares. createFromStr has no case for TIMESTAMP and throws.

Skip the second conversion when the literal is a timestamp that already
carries the declared type. Only a timestamp takes that path; every other
type still goes through createFromStr, which is what gives a literal the
column's type when the two differ. Teaching createFromStr about
TIMESTAMP is the other repair, but it would have to fold a cast to build
the value and has no analyzer to fold with.

Add UnionNode.getConstExprLists() so a test can read the constant rows a
union carries. A TIMESTAMP literal reaches thrift as the backend's
sixteen raw bytes, so that list is where its value is still legible.

Testing:
- New CalciteValuesLiteralTest, 5 tests: a timestamp literal in a VALUES
  row plans and keeps its nanoseconds; a DATE literal and a cast still
  plan; rows of different width keep their own literals. With the change
  reverted the two timestamp tests fail with "Literal unsupported:
  TIMESTAMP" and the other three stay green.
- New calcite.test case, executed through TestCalcitePlanner: the rows
  come back as 2024-01-01 00:02:03.456000000 and
  1970-01-01 00:00:01.234567891. With the change reverted it fails with
  the syntax error above.
- calcite-planner module suite: no class changed its result.

Assisted-by: claude-opus-5 (Claude Code)

Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
---
M fe/src/main/java/org/apache/impala/planner/UnionNode.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/CalciteValuesLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 197 insertions(+), 0 deletions(-)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 1
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 3:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/14012/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 10 Sep 2026 22:12:36 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 20:43:27 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row

Posted by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Steve Carlin, Michael Smith, Impala Public Jenkins, 

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

    http://gerrit.cloudera.org:8080/24793

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

Change subject: IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row
......................................................................

IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row

  set planner=calcite;
  values (timestamp '2024-01-01 00:02:03.456');

  ParseException: Syntax error in line 1:
  values (timestamp '2024-01-01 00:02:03.456')
          ^
  Encountered: TIMESTAMP

The parse error is the original planner's: only Calcite's parser accepts
this statement, and when the Calcite planner refuses it,
Frontend.getTExecRequestWithFallback passes it on as unsupported SQL.
That handoff is separate from the fallback_planner option and happens
with fallback_planner=none too, which is why the failure reads as a
syntax error rather than as a planner refusal.

What the Calcite planner refuses is the literal.
ImpalaValuesRel.getValuesExprs converts each literal of a VALUES row
twice: RexLiteralConverter builds a cast from the literal's text and has
the backend fold it, which is where the TimestampLiteral comes from, and
getLiteralExprWithType then re-creates that literal from its own text
through LiteralExpr.createFromStr, to give it the type the column
declares. createFromStr has no case for TIMESTAMP and throws.

Skip the second conversion when the literal is a timestamp that already
carries the declared type. Only a timestamp takes that path; every other
type still goes through createFromStr, which is what gives a literal the
column's type when the two differ. Teaching createFromStr about
TIMESTAMP is the other repair, but it would have to fold a cast to build
the value and has no analyzer to fold with.

Add UnionNode.getConstExprLists() so a test can read the constant rows a
union carries. A TIMESTAMP literal reaches thrift as the backend's
sixteen raw bytes, so that list is where its value is still legible.

Testing:
- New CalciteValuesLiteralTest, 5 tests: a timestamp literal in a VALUES
  row plans and keeps its nanoseconds; a DATE literal and a cast still
  plan; rows of different width keep their own literals. With the change
  reverted the two timestamp tests fail with "Literal unsupported:
  TIMESTAMP" and the other three stay green.
- New calcite.test case, executed through TestCalcitePlanner: the rows
  come back as 2024-01-01 00:02:03.456000000 and
  1970-01-01 00:00:01.234567891. With the change reverted it fails with
  the syntax error above.
- calcite-planner module suite: no class changed its result.

Assisted-by: claude-opus-5 (Claude Code); gpt-5 (OpenAI Codex)
Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
---
M fe/src/main/java/org/apache/impala/planner/UnionNode.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/CalciteValuesLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 210 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/93/24793/5
-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 5
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 1:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23935/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 1
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 10:58:36 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13992/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 16:22:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org>.
Aleksandr Efimov has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 4:

Rebased; resolved a trivial conflict in calcite.test.


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 4
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 20:40:49 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row
......................................................................

IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row

  set planner=calcite;
  values (timestamp '2024-01-01 00:02:03.456');

  ParseException: Syntax error in line 1:
  values (timestamp '2024-01-01 00:02:03.456')
          ^
  Encountered: TIMESTAMP

The parse error is the original planner's: only Calcite's parser accepts
this statement, and when the Calcite planner refuses it,
Frontend.getTExecRequestWithFallback passes it on as unsupported SQL.
That handoff is separate from the fallback_planner option and happens
with fallback_planner=none too, which is why the failure reads as a
syntax error rather than as a planner refusal.

What the Calcite planner refuses is the literal.
ImpalaValuesRel.getValuesExprs converts each literal of a VALUES row
twice: RexLiteralConverter builds a cast from the literal's text and has
the backend fold it, which is where the TimestampLiteral comes from, and
getLiteralExprWithType then re-creates that literal from its own text
through LiteralExpr.createFromStr, to give it the type the column
declares. createFromStr has no case for TIMESTAMP and throws.

Skip the second conversion when the literal is a timestamp that already
carries the declared type. Only a timestamp takes that path; every other
type still goes through createFromStr, which is what gives a literal the
column's type when the two differ. Teaching createFromStr about
TIMESTAMP is the other repair, but it would have to fold a cast to build
the value and has no analyzer to fold with.

Add UnionNode.getConstExprLists() so a test can read the constant rows a
union carries. A TIMESTAMP literal reaches thrift as the backend's
sixteen raw bytes, so that list is where its value is still legible.

Testing:
- New CalciteValuesLiteralTest, 5 tests: a timestamp literal in a VALUES
  row plans and keeps its nanoseconds; a DATE literal and a cast still
  plan; rows of different width keep their own literals. With the change
  reverted the two timestamp tests fail with "Literal unsupported:
  TIMESTAMP" and the other three stay green.
- New calcite.test case, executed through TestCalcitePlanner: the rows
  come back as 2024-01-01 00:02:03.456000000 and
  1970-01-01 00:00:01.234567891. With the change reverted it fails with
  the syntax error above.
- calcite-planner module suite: no class changed its result.

Assisted-by: claude-opus-5 (Claude Code); gpt-5 (OpenAI Codex)
Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Reviewed-on: http://gerrit.cloudera.org:8080/24793
Reviewed-by: Steve Carlin <sc...@cloudera.com>
Tested-by: Michael Smith <mi...@cloudera.com>
---
M fe/src/main/java/org/apache/impala/planner/UnionNode.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/CalciteValuesLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 210 insertions(+), 0 deletions(-)

Approvals:
  Steve Carlin: Looks good to me, approved
  Michael Smith: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 6
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 5: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 5
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Mon, 05 Oct 2026 20:59:36 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 3: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 18:43:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 4: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 4
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 30 Sep 2026 14:39:10 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 4:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/14176/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 4
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 30 Sep 2026 10:10:05 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Calcite planner: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 5: Code-Review+2

Carryover


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 5
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Mon, 05 Oct 2026 19:31:58 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 3: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 16:15:47 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 4:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/24236/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 4
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 21:03:50 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

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

    http://gerrit.cloudera.org:8080/24793

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

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................

IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

  set planner=calcite;
  values (timestamp '2024-01-01 00:02:03.456');

  ParseException: Syntax error in line 1:
  values (timestamp '2024-01-01 00:02:03.456')
          ^
  Encountered: TIMESTAMP

The parse error is the original planner's: only Calcite's parser accepts
this statement, and when the Calcite planner refuses it,
Frontend.getTExecRequestWithFallback passes it on as unsupported SQL.
That handoff is separate from the fallback_planner option and happens
with fallback_planner=none too, which is why the failure reads as a
syntax error rather than as a planner refusal.

What the Calcite planner refuses is the literal.
ImpalaValuesRel.getValuesExprs converts each literal of a VALUES row
twice: RexLiteralConverter builds a cast from the literal's text and has
the backend fold it, which is where the TimestampLiteral comes from, and
getLiteralExprWithType then re-creates that literal from its own text
through LiteralExpr.createFromStr, to give it the type the column
declares. createFromStr has no case for TIMESTAMP and throws.

Skip the second conversion when the literal is a timestamp that already
carries the declared type. Only a timestamp takes that path; every other
type still goes through createFromStr, which is what gives a literal the
column's type when the two differ. Teaching createFromStr about
TIMESTAMP is the other repair, but it would have to fold a cast to build
the value and has no analyzer to fold with.

Add UnionNode.getConstExprLists() so a test can read the constant rows a
union carries. A TIMESTAMP literal reaches thrift as the backend's
sixteen raw bytes, so that list is where its value is still legible.

Testing:
- New CalciteValuesLiteralTest, 5 tests: a timestamp literal in a VALUES
  row plans and keeps its nanoseconds; a DATE literal and a cast still
  plan; rows of different width keep their own literals. With the change
  reverted the two timestamp tests fail with "Literal unsupported:
  TIMESTAMP" and the other three stay green.
- New calcite.test case, executed through TestCalcitePlanner: the rows
  come back as 2024-01-01 00:02:03.456000000 and
  1970-01-01 00:00:01.234567891. With the change reverted it fails with
  the syntax error above.
- calcite-planner module suite: no class changed its result.

Assisted-by: claude-opus-5 (Claude Code)

Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
---
M fe/src/main/java/org/apache/impala/planner/UnionNode.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/CalciteValuesLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 196 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/93/24793/2
-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Steve Carlin, Michael Smith, Impala Public Jenkins, 

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

    http://gerrit.cloudera.org:8080/24793

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

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................

IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

  set planner=calcite;
  values (timestamp '2024-01-01 00:02:03.456');

  ParseException: Syntax error in line 1:
  values (timestamp '2024-01-01 00:02:03.456')
          ^
  Encountered: TIMESTAMP

The parse error is the original planner's: only Calcite's parser accepts
this statement, and when the Calcite planner refuses it,
Frontend.getTExecRequestWithFallback passes it on as unsupported SQL.
That handoff is separate from the fallback_planner option and happens
with fallback_planner=none too, which is why the failure reads as a
syntax error rather than as a planner refusal.

What the Calcite planner refuses is the literal.
ImpalaValuesRel.getValuesExprs converts each literal of a VALUES row
twice: RexLiteralConverter builds a cast from the literal's text and has
the backend fold it, which is where the TimestampLiteral comes from, and
getLiteralExprWithType then re-creates that literal from its own text
through LiteralExpr.createFromStr, to give it the type the column
declares. createFromStr has no case for TIMESTAMP and throws.

Skip the second conversion when the literal is a timestamp that already
carries the declared type. Only a timestamp takes that path; every other
type still goes through createFromStr, which is what gives a literal the
column's type when the two differ. Teaching createFromStr about
TIMESTAMP is the other repair, but it would have to fold a cast to build
the value and has no analyzer to fold with.

Add UnionNode.getConstExprLists() so a test can read the constant rows a
union carries. A TIMESTAMP literal reaches thrift as the backend's
sixteen raw bytes, so that list is where its value is still legible.

Testing:
- New CalciteValuesLiteralTest, 5 tests: a timestamp literal in a VALUES
  row plans and keeps its nanoseconds; a DATE literal and a cast still
  plan; rows of different width keep their own literals. With the change
  reverted the two timestamp tests fail with "Literal unsupported:
  TIMESTAMP" and the other three stay green.
- New calcite.test case, executed through TestCalcitePlanner: the rows
  come back as 2024-01-01 00:02:03.456000000 and
  1970-01-01 00:00:01.234567891. With the change reverted it fails with
  the syntax error above.
- calcite-planner module suite: no class changed its result.

Assisted-by: claude-opus-5 (Claude Code); gpt-5 (OpenAI Codex)
Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
---
M fe/src/main/java/org/apache/impala/planner/UnionNode.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/CalciteValuesLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 210 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/93/24793/4
-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 4
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 1:

(1 comment)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/24793/1/java/calcite-planner/src/test/java/org/apache/impala/calcite/service/CalciteValuesLiteralTest.java
File java/calcite-planner/src/test/java/org/apache/impala/calcite/service/CalciteValuesLiteralTest.java:

http://gerrit.cloudera.org:8080/#/c/24793/1/java/calcite-planner/src/test/java/org/apache/impala/calcite/service/CalciteValuesLiteralTest.java@27
PS1, Line 27: import org.apache.calcite.rex.RexLiteral;
unused import: org.apache.calcite.rex.RexLiteral



-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 1
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 10:35:59 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org>.
Aleksandr Efimov has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24793/2/fe/src/main/java/org/apache/impala/planner/UnionNode.java
File fe/src/main/java/org/apache/impala/planner/UnionNode.java:

http://gerrit.cloudera.org:8080/#/c/24793/2/fe/src/main/java/org/apache/impala/planner/UnionNode.java@105
PS2, Line 105:   public List<List<Expr>> getConstExprLists() { return constExprLists_; }
> Slightly torn here, I'll leave it up to you to decide:
I went with the copy in PS3. The accessor is marked @VisibleForTesting and returns an immutable snapshot of both list levels.



-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 10 Sep 2026 18:05:38 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24793/2/fe/src/main/java/org/apache/impala/planner/UnionNode.java
File fe/src/main/java/org/apache/impala/planner/UnionNode.java:

http://gerrit.cloudera.org:8080/#/c/24793/2/fe/src/main/java/org/apache/impala/planner/UnionNode.java@105
PS2, Line 105:   public List<List<Expr>> getConstExprLists() { return constExprLists_; }
Slightly torn here, I'll leave it up to you to decide:

constExprLists_ is not declared as immutable, so theoretically a caller can change it. 

Since it's only being used in the test environment (hopefully forever), maybe it's worth a copy and add a comment to say that it's inefficient?

Or maybe just leave it as/is, since that is a bit too much nitpicking and overkill to keep as immutable as possible?



-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 10 Sep 2026 14:27:10 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23936/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 11:15:06 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 3:

Has a merge conflict that needs manual resolution.


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 16:15:59 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 3:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23968/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 10 Sep 2026 18:21:02 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 3: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Fri, 11 Sep 2026 02:34:45 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 1:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13988/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 1
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 10:33:50 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13989/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 10:59:22 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 2: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/13989/


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 2
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 15:26:32 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24793 )

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................


Patch Set 1: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 1
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 08 Sep 2026 15:00:49 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

Posted by "Aleksandr Efimov (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Steve Carlin, Michael Smith, Impala Public Jenkins, 

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

    http://gerrit.cloudera.org:8080/24793

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

Change subject: IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row
......................................................................

IMPALA-15338: Plan a TIMESTAMP literal in a VALUES row

  set planner=calcite;
  values (timestamp '2024-01-01 00:02:03.456');

  ParseException: Syntax error in line 1:
  values (timestamp '2024-01-01 00:02:03.456')
          ^
  Encountered: TIMESTAMP

The parse error is the original planner's: only Calcite's parser accepts
this statement, and when the Calcite planner refuses it,
Frontend.getTExecRequestWithFallback passes it on as unsupported SQL.
That handoff is separate from the fallback_planner option and happens
with fallback_planner=none too, which is why the failure reads as a
syntax error rather than as a planner refusal.

What the Calcite planner refuses is the literal.
ImpalaValuesRel.getValuesExprs converts each literal of a VALUES row
twice: RexLiteralConverter builds a cast from the literal's text and has
the backend fold it, which is where the TimestampLiteral comes from, and
getLiteralExprWithType then re-creates that literal from its own text
through LiteralExpr.createFromStr, to give it the type the column
declares. createFromStr has no case for TIMESTAMP and throws.

Skip the second conversion when the literal is a timestamp that already
carries the declared type. Only a timestamp takes that path; every other
type still goes through createFromStr, which is what gives a literal the
column's type when the two differ. Teaching createFromStr about
TIMESTAMP is the other repair, but it would have to fold a cast to build
the value and has no analyzer to fold with.

Add UnionNode.getConstExprLists() so a test can read the constant rows a
union carries. A TIMESTAMP literal reaches thrift as the backend's
sixteen raw bytes, so that list is where its value is still legible.

Testing:
- New CalciteValuesLiteralTest, 5 tests: a timestamp literal in a VALUES
  row plans and keeps its nanoseconds; a DATE literal and a cast still
  plan; rows of different width keep their own literals. With the change
  reverted the two timestamp tests fail with "Literal unsupported:
  TIMESTAMP" and the other three stay green.
- New calcite.test case, executed through TestCalcitePlanner: the rows
  come back as 2024-01-01 00:02:03.456000000 and
  1970-01-01 00:00:01.234567891. With the change reverted it fails with
  the syntax error above.
- calcite-planner module suite: no class changed its result.

Assisted-by: claude-opus-5 (Claude Code); gpt-5 (OpenAI Codex)
Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
---
M fe/src/main/java/org/apache/impala/planner/UnionNode.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/CalciteValuesLiteralTest.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
4 files changed, 210 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/93/24793/3
-- 
To view, visit http://gerrit.cloudera.org:8080/24793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If8b5eebe9b5fa94066ff2f9410cab799fc6a3497
Gerrit-Change-Number: 24793
Gerrit-PatchSet: 3
Gerrit-Owner: Aleksandr Efimov <dz...@gmail.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>