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

zhen wang commented on CALCITE-2002:
------------------------------------

https://github.com/apache/calcite/pull/633

PR created.  [~julianhyde] let me know your comments. 

Marc's guess is correct.
when the table function literal consider column uniqueness, it didn't take 
columns into consideration.
thus, the uniqueness of all columns hinted the optimizer to do invalid 
optimization on the plans. thus the issue.

> Distinct query against in-memory values is sometimes wrong
> ----------------------------------------------------------
>
>                 Key: CALCITE-2002
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2002
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.14.0
>            Reporter: Marc Prud'hommeaux
>            Assignee: Julian Hyde
>            Priority: Major
>
> The following output is clearly wrong:
> {code:title=baddistinct.sql|borderStyle=solid}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT DISTINCT T.B FROM 
> (VALUES (1, 'X'),(2, 'Y'),(3, 'X'),(4, 'X')) AS T(A, B);
> +---+
> | B |
> +---+
> | X |
> | Y |
> | X |
> | X |
> +---+
> 4 rows selected (0.014 seconds)
> {code}
> I'm guessing it is distinct-ing against the complete value tuple rather than 
> the selected column, since the following is correct:
> {code:title=gooddistinct.sql|borderStyle=solid}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT DISTINCT T.B FROM 
> (VALUES (1, 'X'),(2, 'Y'),(3, 'X'),(3, 'X')) AS T(A, B);
> +---+
> | B |
> +---+
> | X |
> | Y |
> +---+
> 2 rows selected (0.013 seconds)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to