Jonathan A Sternberg created CALCITE-5542:
---------------------------------------------
Summary: ReduceExpressionsRule incorrectly flags subqueries as
reducible
Key: CALCITE-5542
URL: https://issues.apache.org/jira/browse/CALCITE-5542
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.33.0
Reporter: Jonathan A Sternberg
The `ReduceExpressionsRule` incorrectly flags subqueries as reducible
constants. Since a subquery is a type of call, it visits the arguments of the
subquery to determine whether it is reducible and, generally, there are no
arguments so the subquery gets marked as reducible.
Because it's flagged as reducible, the expression with the subquery gets passed
to a `RexProgram` which can't handle subqueries.
I suspect the fix is to just mark all subqueries as irreducible. If a reducible
subquery is wanted, it should be handled through a different planner rule.
Currently, using the `ReduceExpressionsRule` when a subquery is present causes
an exception to be thrown when attempting to reduce the expression.
This is the code which I believe is incorrect:
https://github.com/apache/calcite/blob/3dae2519f8943d287688ddff8256d22f90ebaf67/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java#L1088-L1091
--
This message was sent by Atlassian Jira
(v8.20.10#820010)