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

LakeShen commented on CALCITE-5915:
-----------------------------------

I find that in RelDecorrelator#decorrelateQuery method,it will Re-propagate the 
hints.

!image-2023-08-13-23-11-56-589.png|width=712,height=363!

Normally withExpand is set to false, and user need to rewrite RexSubQuery with 
the SubQueryRemoveRule rule, which should propagate hint once. The hint is then 
propagated again in the RelDecorrelator#decorrelateQuery method.

If you set withExpand to false and don't use SubQueryRemoveRule to overwrite 
RexSubQuery, you won't be able to propagate hints, because propagation hints 
can only propagate between relNodes. 

But this plan is also difficult to optimize by the general optimizer, it is not 
a normal SQL plan.

The above is my understanding.If it has some errors,pls correct me,thanks.

> Missing SQL hints in not-expanded subqueries. 
> ----------------------------------------------
>
>                 Key: CALCITE-5915
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5915
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Vladimir Steshin
>            Priority: Minor
>         Attachments: SqlHintsInSubqueriesWithDisabledExpanding.java, 
> image-2023-08-13-23-11-56-589.png
>
>
> Not sure if it is a bug becuase the query plans in this case might not be 
> final and require further expanding, but the SQL hints might not be 
> propagated to subqueries when SqlToRelConverter#withExpand==false. This 
> happens because hints are pushed down with 
> _RelOptUtil#RelHintPropagateShuttle_ and 
> _RelOptUtil#SubTreeHintPropagateShuttle_ which travese through 
> _RelNode#getInputs()_. But what if node is not accessible as other node’s 
> input like keeping in _LogicalFilter#condition_? Then the shuttles skip such 
> nodes.
> Test attached.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to