[ https://issues.apache.org/jira/browse/CALCITE-2002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16371972#comment-16371972 ]
Julian Hyde commented on CALCITE-2002: -------------------------------------- Thanks for the PR: * Can you please add a test to RelMetadataTest? It's useful to have unit tests for metadata. * Is the test case in JdbcTest.testDistinctTableFunction minimal? Do you need the view? * We are trying to keep "simple" SQL tests in quidem (.iq) rather than java files, so could you move it to misc.iq? Here's what I added (currently fails, of course): {code} diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq index ba2ebd6..7bdc983 100644 --- a/core/src/test/resources/sql/misc.iq +++ b/core/src/test/resources/sql/misc.iq @@ -1051,6 +1051,19 @@ order by substring(job from 2 for 1), -deptno; !ok +# [CALCITE-2002] DISTINCT applied to VALUES returns wrong result +SELECT DISTINCT T.B +FROM (VALUES (1, 'X'),(2, 'Y'),(3, 'X'),(4, 'X')) AS T(A, B); ++---+ +| B | ++---+ +| X | +| Y | ++---+ +(2 rows) + +!ok + # [CALCITE-2180] Invalid code generated for negative of byte and short values select -deptno as d from "scott".dept; {code} > 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)