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

Stamatis Zampetakis commented on CALCITE-4251:
----------------------------------------------

Hey [~xzh_dz], it seems that the changes that were done as part of the PR#2189 
in Lopt*Join classes changed unintentionally the behavior of the rules. Can you 
clarify what was the original goal for adding a disjunction with 
!colOrigin.isDerived() in these classes just to be 100% sure that the fix in 
CALCITE-6737 is sound.

> Get the origin column, even if it is derived
> --------------------------------------------
>
>                 Key: CALCITE-4251
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4251
>             Project: Calcite
>          Issue Type: Wish
>            Reporter: xzh_dz
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.27.0
>
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> A case:
> {code:java}
> final String sql1 = ""
>     + "select empno, sum(sal) as all_sal\n"
>     + "from emp\n"
>     + "group by empno";
> {code}
> When i try to get the `all_sal` origin column field,it will return null and 
> it is derived. we always get the origin column although it is derived. We 
> should overload this method and determine whether the column is derived by 
> setting parameters.
>  org.apache.calcite.rel.metadata.RelMetadataQuery#getColumnOrigin
> {code:java}
> // code placeholder
> public RelColumnOrigin getColumnOrigin(RelNode rel, int column) {
>   final Set<RelColumnOrigin> origins = getColumnOrigins(rel, column);
>   if (origins == null || origins.size() != 1) {
>     return null;
>   }
>   final RelColumnOrigin origin = Iterables.getOnlyElement(origins);
>   return origin.isDerived() ? null : origin;
> }
> {code}
>  
>  
>  
>  



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

Reply via email to