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

Jesus Camacho Rodriguez commented on CALCITE-987:
-------------------------------------------------

The reason to use validateResult method seems to be:

{noformat}
    // Never let the result go below 1, as it will result in incorrect
    // calculations if the row-count is used as the denominator in a
    // division expression.  Also, cap the value at the max double value
    // to avoid calculations using infinity.
{noformat}

IMO, the metadata providers should not validate the result, as this is just 
metadata information. Instead, it should be the method that calls e.g. 
getDistinctRowCount, the one that should check that the value is not zero if it 
wants to use it as denominator in a division. Thus, I would actually change the 
original getDistinctRowCount method so it does not call {{validateResult}}.

[~julianhyde], what's your take on this?

> Push limit 0 will result in an infinite loop
> --------------------------------------------
>
>                 Key: CALCITE-987
>                 URL: https://issues.apache.org/jira/browse/CALCITE-987
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Pengcheng Xiong
>            Assignee: Pengcheng Xiong
>         Attachments: CALCITE-987.01.patch
>
>
> We use "checkInputForCollationAndLimit" in RelMdUtil.java to check the input 
> #rows. However, it calls RelMetadataQuery.getRowCount which will validate the 
> #rows. The validation will change #row=0 to #row=1. This will result in an 
> infinite loop to push limit. The affected rules include 
> SortUnionTransposeRule and any Sort***TransposeRules that call  
> checkInputForCollationAndLimit.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to