You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Benchao Li (Jira)" <ji...@apache.org> on 2023/02/26 02:49:00 UTC

[jira] [Commented] (CALCITE-5542) ReduceExpressionsRule incorrectly flags subqueries as reducible

    [ https://issues.apache.org/jira/browse/CALCITE-5542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17693570#comment-17693570 ] 

Benchao Li commented on CALCITE-5542:
-------------------------------------

[~jsternberg] I linked the discussion thread to this Jira.

As the discussion in ML, we'd love to see the complete description of the bug. E.g., what is current behavior, and what's is the behavior you expects. A good UT would help a lot.

As [~jhyde] said in the ML, we would give it a try to allow {{RexSubQuery}} to appear in {{RexProgram}}. I agree with that statement, although I don't know any use case which prefers this way now. Towards this direction, we may need more works, to pass around the {{RexSubQuery}} around in the stage of optimizing. 

> 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
>            Priority: Minor
>
> 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)