You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Steve Carlin (Code Review)" <ge...@cloudera.org> on 2025/11/28 20:13:04 UTC

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Steve Carlin has uploaded this change for review. ( http://gerrit.cloudera.org:8080/23723


Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
because folding this creates an inexact number, and this is
problematic for partition pruning directory names on double
columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaJoinSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
12 files changed, 903 insertions(+), 9 deletions(-)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 1
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 7: Code-Review+1

(4 comments)

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java@208
PS5, Line 208:       BigDecimal value = (BigDecimal) RexLiteral.value(literal);
> No side effects, blech.  Just a line that needs to be removed.
Done


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java@76
PS5, Line 76:       List<RexNode> operands = splitAndConjuncts
> Not sure what you mean by optimization here.
Ack


http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
File testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test:

http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test@97
PS6, Line 97:    extrapolated-rows=disabled max-scan-range-rows=12.24M
> No idea :(
Ack


http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
File testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test:

http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test@52
PS6, Line 52: Per-Host Resource Estimates: Memory=7.31GB
> constant folding :). 
Ack



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 7
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 23:57:32 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 1:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21053/ : 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/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 1
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Comment-Date: Fri, 28 Nov 2025 20:40:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Fang-Yu Rao, Riza Suminto, Pranav Lodha, Joe McDonnell, Michael Smith, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
because folding this creates an inexact number, and this is
problematic for partition pruning directory names on double
columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaJoinSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q91.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
76 files changed, 5,961 insertions(+), 4,962 deletions(-)


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 2
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Fang-Yu Rao, Riza Suminto, Pranav Lodha, Joe McDonnell, Michael Smith, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
because folding this creates an inexact number, and this is
problematic for partition pruning directory names on double
columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q06.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q07.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q08.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q13.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q17.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q19.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q25.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q27.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q31.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q35a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q36.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q42.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q48.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q50.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q52.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q55.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q58.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q71.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q72.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q76.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q78.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q89.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
99 files changed, 5,913 insertions(+), 4,959 deletions(-)


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 5
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 6:

(7 comments)

http://gerrit.cloudera.org:8080/#/c/23723/5//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/23723/5//COMMIT_MSG@24
PS5, Line 24: because folding this creates an inexact number, and this is
nit: fix inconsistent formatting between this and the next bullet point.


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java@208
PS5, Line 208:       Type decimalType = ImpalaTypeConverter.createImpalaType(literal.getType());
Why is this return value ignored? If this is just executed for the side-effect, it'd be clearer not to capture the return value.


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java@76
PS5, Line 76:       List<RexNode> operands = splitAndConjuncts
Is this just an optimization to avoid needing to walk the whole tree?


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java@58
PS5, Line 58:     newCondition = reducedExprs.get(0);
A precondition that there's only one result would be nice.


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java@78
PS5, Line 78:     reducedValues.add(((RexCall)constExps.get(0)).getOperands().get(0));
nit: repeating all the unwrapping that rexNodeIsCharCastOfChar seems odd to me. Maybe this would be more straight-forward as a couple nested ifs?

This formulation does also work, and is at least clear in its intention.


http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
File testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test:

http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test@97
PS6, Line 97:    extrapolated-rows=disabled max-scan-range-rows=12.24M
Any idea why this changed?


http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
File testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test:

http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test@52
PS6, Line 52: Per-Host Resource Estimates: Memory=7.31GB
This is a substantial change, what happened?



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 6
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 18:23:07 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 9: Code-Review+1


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 16:37:09 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 8:

(1 comment)

Yes, this does replace now()

http://gerrit.cloudera.org:8080/#/c/23723/8/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java:

http://gerrit.cloudera.org:8080/#/c/23723/8/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java@292
PS8, Line 292: 65536
> Nit: Should we use LiteralExpr.MAX_STRING_LITERAL_SIZE here instead?
Done



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 8
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 14:44:38 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 9: Code-Review+2

This looks good to me


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 19:57:26 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 5:

(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/23723/5/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
File java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java@69
PS5, Line 69:   protected static final Logger LOG = LoggerFactory.getLogger(TestReduceExprShuttle.class.getName());
line too long (101 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 5
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 03:09:43 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 7:

(7 comments)

http://gerrit.cloudera.org:8080/#/c/23723/5//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/23723/5//COMMIT_MSG@24
PS5, Line 24:   because folding this creates an inexact number, and this is
> nit: fix inconsistent formatting between this and the next bullet point.
Done


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java@208
PS5, Line 208:       BigDecimal value = (BigDecimal) RexLiteral.value(literal);
> Why is this return value ignored? If this is just executed for the side-eff
No side effects, blech.  Just a line that needs to be removed.


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java@76
PS5, Line 76:       List<RexNode> operands = splitAndConjuncts
> Is this just an optimization to avoid needing to walk the whole tree?
Not sure what you mean by optimization here.

The default case (previously the only case) was to split the conjunct into its "and" conditions because each individual "and" could be used for pruning.

This commit adds a secondary purpose: We use constant folding over the whole expression.  In this case, splitting out into "and" conjuncts doesn't really make much sense since the whole folded expression would need to be recreated.


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java@58
PS5, Line 58:     executor.reduce(rexBuilder, ImmutableList.of(newCondition), reducedExprs);
> A precondition that there's only one result would be nice.
Done


http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java:

http://gerrit.cloudera.org:8080/#/c/23723/5/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java@78
PS5, Line 78:     reducedValues.add(((RexCall)constExps.get(0)).getOperands().get(0));
> nit: repeating all the unwrapping that rexNodeIsCharCastOfChar seems odd to
Idk.  I just felt the code was clearer this way?  I assume you mean that I should get rid of the rexNodeIs... method, bring the "ifs" into this method?  I can't get my head around something that looks cleaner than this, but if you have a specific suggestion, I'll consider it.


http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
File testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test:

http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test@97
PS6, Line 97:    extrapolated-rows=disabled max-scan-range-rows=12.24M
> Any idea why this changed?
No idea :(

Apparently, this value isn't checked when running the tests.  I harcoded/forced the value to something way higher and the test still passed.

This commit didn't change this value.  I reverted this commit, ran again, and the current master commit also produces 12.24M.

In this case, since there was a failure, I blindly copied all the ".test" files from the test location.  I must have not done that on a previous commit.

Not sure what the reasons are for not checking this value, but that would be outside the scope of this commit.  I could file a Jira, but I'm not sure if this was done on purpose.


http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
File testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test:

http://gerrit.cloudera.org:8080/#/c/23723/6/testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test@52
PS6, Line 52: Per-Host Resource Estimates: Memory=7.31GB
> This is a substantial change, what happened?
constant folding :). 

Clearly not obvious based on the info here, so I traced this in the debugger.  

This specific value changed due to the number of distinct values coming out of the date_dim table.

The number of distinct values specifically for d_year changed.  Previously, without constant folding, it estimated the number of distinct values at 196.  With constant folding, it determined that the number of distinct years were 3.

There is a cap on the number of groups, so the ratio is slightly smaller, but this accounts for the huge difference.



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 7
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 23:47:43 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Fang-Yu Rao, Riza Suminto, Pranav Lodha, Joe McDonnell, Michael Smith, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
  because folding this creates an inexact number, and this is
  problematic for partition pruning directory names on double
  columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q06.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q07.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q08.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q13.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q17.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q19.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q25.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q27.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q31.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q35a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q36.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q42.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q48.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q50.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q52.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q55.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q58.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q71.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q72.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q76.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q78.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q89.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
99 files changed, 5,914 insertions(+), 4,959 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/23/23723/7
-- 
To view, visit http://gerrit.cloudera.org:8080/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 7
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 8:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21513/ : 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/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 8
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 01:26:02 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 5:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21492/ : 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/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 5
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 04:19:57 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 8: Code-Review+1

(1 comment)

Does this replace now() (and similar current time functions) with the current timestamp?

http://gerrit.cloudera.org:8080/#/c/23723/8/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java:

http://gerrit.cloudera.org:8080/#/c/23723/8/java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java@292
PS8, Line 292: 65536
Nit: Should we use LiteralExpr.MAX_STRING_LITERAL_SIZE here instead?



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 8
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 00:55:57 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


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/23723/1/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
File java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java:

http://gerrit.cloudera.org:8080/#/c/23723/1/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java@69
PS1, Line 69:   protected static final Logger LOG = LoggerFactory.getLogger(TestReduceExprShuttle.class.getName());
line too long (101 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 1
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Comment-Date: Fri, 28 Nov 2025 20:15:25 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 9:

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


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 14:45:08 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 9:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21519/ : 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/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 15:45:17 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 9: Verified+1


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 20:22:30 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 7:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21512/ : 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/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 7
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 00:57:12 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 6:

(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/23723/6/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
File java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java:

http://gerrit.cloudera.org:8080/#/c/23723/6/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java@69
PS6, Line 69:   protected static final Logger LOG = LoggerFactory.getLogger(TestReduceExprShuttle.class.getName());
line too long (101 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 6
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 18:10:54 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 6:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21508/ : 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/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 6
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 19:23:06 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
  because folding this creates an inexact number, and this is
  problematic for partition pruning directory names on double
  columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Reviewed-on: http://gerrit.cloudera.org:8080/23723
Reviewed-by: Michael Smith <mi...@cloudera.com>
Reviewed-by: Joe McDonnell <jo...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q06.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q07.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q08.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q13.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q17.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q19.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q25.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q27.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q31.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q35a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q36.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q42.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q48.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q50.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q52.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q55.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q58.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q71.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q72.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q76.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q78.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q89.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
99 files changed, 5,911 insertions(+), 4,959 deletions(-)

Approvals:
  Michael Smith: Looks good to me, but someone else must approve
  Joe McDonnell: Looks good to me, approved
  Impala Public Jenkins: Verified

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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 10
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 7:

(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/23723/7/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
File java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java:

http://gerrit.cloudera.org:8080/#/c/23723/7/java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java@69
PS7, Line 69:   protected static final Logger LOG = LoggerFactory.getLogger(TestReduceExprShuttle.class.getName());
line too long (101 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 7
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Tue, 27 Jan 2026 23:48:56 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Fang-Yu Rao, Riza Suminto, Pranav Lodha, Joe McDonnell, Michael Smith, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
because folding this creates an inexact number, and this is
problematic for partition pruning directory names on double
columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q06.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q07.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q08.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q13.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q17.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q19.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q25.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q27.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q31.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q35a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q36.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q42.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q48.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q50.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q52.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q55.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q58.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q71.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q72.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q76.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q78.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q89.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
99 files changed, 5,913 insertions(+), 4,959 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/23/23723/6
-- 
To view, visit http://gerrit.cloudera.org:8080/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 6
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Fang-Yu Rao, Riza Suminto, Pranav Lodha, Joe McDonnell, Michael Smith, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
  because folding this creates an inexact number, and this is
  problematic for partition pruning directory names on double
  columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q06.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q07.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q08.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q13.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q17.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q19.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q25.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q27.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q31.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q35a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q36.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q42.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q48.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q50.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q52.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q55.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q58.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q71.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q72.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q76.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q78.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q89.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
99 files changed, 5,909 insertions(+), 4,959 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/23/23723/8
-- 
To view, visit http://gerrit.cloudera.org:8080/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 8
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................


Patch Set 8: Code-Review+1


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 8
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 00:14:12 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13712: Calcite Planner - Enable constant folding

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Fang-Yu Rao, Riza Suminto, Pranav Lodha, Joe McDonnell, Michael Smith, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13712: Calcite Planner - Enable constant folding
......................................................................

IMPALA-13712: Calcite Planner - Enable constant folding

Constant folding is enabled by this patch.

Calcite does constant folding via the RexExecutor.reduce()
method. However, we need to use Impala's constant folding algorithm
to ensure that Impala expressions are folded. This is done through
the derived class ImpalaRexExecutor and is called from the
Simplify rules.

The ImpalaRexExecutor calls an internal shuttle class which
recursively walks through the RexNode which checks if portions of
the expression can be constant folded.

Some expressions are not folded due to various reasons:

- We avoid folding 'cast(1.2 as double)' type expressions
  because folding this creates an inexact number, and this is
  problematic for partition pruning directory names on double
  columns which contain the exact number (1.2 in this case).

- Interval expressions are skipped temporarily since the Expr
  class generated is not meant to be simplified. However, an
  Expr object that contains an IntervalExpr may be simplified.

There is a special case that needed to be handled for a values
query with different sized arguments across rows. In Calcite
version 1.40 (not yet upgraded as of this commit), an extra
cast is added around smaller strings to ensure the char(x)
is the same size across all rows. However, this adds extra spaces
to the string which causes results different from the original
Impala planner. This must be caught before Calcite converts the
abstract syntax tree into a RelNode logical tree. A special
RexExecutor has been created to handle this which looks for char
casts around a char literal and removes it. This is fine because
the literal will be changed into a string in the "coercenodes"
module.

Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
---
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/util/ExprConjunctsConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaFilterSimplifyRule.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectSimplifyRule.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/RemoveUnraggedCharCastRexExecutor.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteRelNodeConverter.java
A java/calcite-planner/src/test/java/org/apache/impala/planner/TestReduceExprShuttle.java
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q03.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q04.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q05.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q06.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q07.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q08.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q10a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q11.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q12.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q13.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q14b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q16.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q17.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q19.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q20.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q21.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q22.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q23b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q25.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q27.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q28.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q29.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q31.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q32.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q33.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q34.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q35a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q36.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q37.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q38.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39a.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q39b.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q40.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q41.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q42.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43-verbose.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q43.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q46.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q47.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q48.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q50.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q51.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q52.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q53.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q55.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q56.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q57.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q58.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q60.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q61.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q62.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q63.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q64.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q65.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q66.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q67.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q68.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q69.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q70.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q71.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q72.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q73.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q74.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q75.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q76.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q77.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q78.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q79.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q80.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q82.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q86.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q87.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q88.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q89.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q92.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q94.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q95.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q97.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q98.test
M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q99.test
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
99 files changed, 5,911 insertions(+), 4,959 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/23/23723/9
-- 
To view, visit http://gerrit.cloudera.org:8080/23723
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I98c21ef75b2f5f8e3390ff5de5fdf45d9645b326
Gerrit-Change-Number: 23723
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Pranav Lodha <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@gmail.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>