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

Stamatis Zampetakis commented on CALCITE-4281:
----------------------------------------------

Getting the lowest max-row-count from the relational expressions in a sub-set 
makes sense for most cases. For sure, it would be better than the current 
situation that still has the workaround for CALCITE-1018. I read the related 
JIRAs and it seems that in the past the rather intuitive proposal was blocked 
by more ambitious initiatives for more generic solutions (CALCITE-3963).

The rather simplistic approach in the description seems worth to address 
independently given the number of times that it popped up in discussions and 
tickets. I am thinking that the "fold" or any alternative design can be an 
additional improvement that could be handled separately.

Are there any objections in moving this forward based on the proposal by 
[~weijie]? 

Is someone willing to create and submit PR for this specific case of max row 
count?

> fix getMaxRowCount for RelSubset to return reasonable values 
> -------------------------------------------------------------
>
>                 Key: CALCITE-4281
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4281
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.25.0
>            Reporter: chunfeng pei
>            Priority: Major
>
> currently getMaxRowCount(RelSubset rel, RelMetadataQuery mq) only have a 
> short term fix for CALCITE-1018.  
> https://issues.apache.org/jira/browse/CALCITE-1018
> we need a complete solution for this, as suggested in 
> https://issues.apache.org/jira/browse/CALCITE-1048
> quotes: Clearly RelMdMaxRowCount of a RelSubset should be the lowest 
> max-row-count of any relational expression in that subset. Each kind of 
> metadata should have a way of deriving a subset's value from the constituent 
> rel values; in the case of RelMdMaxRowCount the roll-up function is "min".
> also a sample solution provided by [~weijie] : 
>  public Double getMaxRowCount(RelSubset rel, RelMetadataQuery mq) {    Double 
> lowest = Double.POSITIVE_INFINITY;    for (RelNode node : rel.getRels()) {    
>   Double maxRowCount = mq.getMaxRowCount(node);      if (maxRowCount == null) 
> {        continue;
>       }      if (lowest.compareTo(maxRowCount) > 0) \{
>         lowest = maxRowCount;
>       }
>     }    return lowest;
>   }
> then comments from [~jhyde] :
> quote: I was thinking of doing the same thing in a more abstract way, namely 
> providing a 
> "[fold|https://en.wikipedia.org/wiki/Fold_(higher-order_function)]" function.
> this ticket is opened to address this issue. this is also related to the 
> following ticket:
> https://issues.apache.org/jira/browse/CALCITE-3963



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

Reply via email to