[
https://issues.apache.org/jira/browse/CALCITE-5069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17514608#comment-17514608
]
Xurenhe commented on CALCITE-5069:
----------------------------------
My formula:
* all = false, return original rowCount
* all = true, return rowCount * 2
I did encounter the case, such as like duplicates data in the {{dept}} table.
eg:
{code:java}
SELECT c1
,c2
FROM ( VALUES
( 0 , 'a' ) ,
( 1 , 'b' ) ,
( 2 , 'c' ) ,
( 0 , 'a' ) ,
( 0 , 'a' ) ) AS t1 ( c1 , c2 )
EXCEPT ALL
SELECT c1
,c2
FROM ( VALUES
( 0 , 'a' ) ,
( 3 , 'b' ) ) AS t1 ( c1 , c2 )
{code}
Yes you are right, keeping original formula is more safe.
I need think about using *RelMdMaxRowCount#getMaxRowCount* to solve my
estimated problem.
[~julianhyde]
Thanks for your guidance, and I learn more from you.
> Method of minus's getRowCount has not consider 'except all'
> -----------------------------------------------------------
>
> Key: CALCITE-5069
> URL: https://issues.apache.org/jira/browse/CALCITE-5069
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Xurenhe
> Assignee: Xurenhe
> Priority: Major
>
> Current code of *RelMdRowCount* has not consider 'except all', it should be
> double.
> It's similar to
> [CALCITE-3287|https://issues.apache.org/jira/browse/CALCITE-3287] and
> [CALCITE-3988|https://issues.apache.org/jira/browse/CALCITE-3988]
> CODE: *RelMdRowCount#getRowCount(Minus, RelMetadataQuery)*
>
> {code:java}
> // now
> public @Nullable Double getRowCount(Minus rel, RelMetadataQuery mq) {
> Double rowCount = null;
> for (RelNode input : rel.getInputs()) {
> Double partialRowCount = mq.getRowCount(input);
> if (rowCount == null
> || partialRowCount != null && partialRowCount < rowCount) {
> rowCount = partialRowCount;
> }
> }
> return rowCount;
> }
> // right
> public @Nullable Double getRowCount(Minus rel, RelMetadataQuery mq) {
> Double rowCount = null;
> for (RelNode input : rel.getInputs()) {
> Double partialRowCount = mq.getRowCount(input);
> if (rowCount == null
> || partialRowCount != null && partialRowCount < rowCount) {
> rowCount = partialRowCount;
> }
> }
> if (rowCount == null || !rel.all) {
> return rowCount;
> } else {
> return rowCount * 2;
> }
> }{code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)