[
https://issues.apache.org/jira/browse/CALCITE-987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15026639#comment-15026639
]
Jesus Camacho Rodriguez commented on CALCITE-987:
-------------------------------------------------
[~julianhyde], +1 to the idea of adding a maximum row count, I think we had
even discussed about that previously.
I have just checked the latest patch by [~pxiong]. The patch relies on
estimated row count to obtain the maximum row count. I think we should rather
provide an actual different metadata provider and method.
In some cases, estimated row count might be equal to max row count, but not in
all cases. For instance, consider a join operator with two inputs that produce
n and m tuples, respectively. If no PK/FK relationship is present, we rely on
estimated selectivity to calculate estimated row count, but the maximum row
count should not be the result of applying Math.ceil to estimated row count.
Rather, the max row count should be n * m.
We do not need to implement maximum row count for every operator in this patch;
we can delegate the implementation of the method to the different systems using
Calcite. But at least, the patch should provide the implementation for max row
count for the Sort operator (that might be equal to estimated row count in this
case) so it works as expected with LimitJoinTranspose and LimitUnionTranspose
rules.
> 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, CALCITE-987.02.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)