Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2002

DISTINCT applied to VALUES returns wrong result

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.14.0
    • 1.16.0
    • None
    • None

    Description

      The following output is clearly wrong:

      baddistinct.sql
      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)
      

      I'm guessing it is distinct-ing against the complete value tuple rather than the selected column, since the following is correct:

      gooddistinct.sql
      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)
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            julianhyde Julian Hyde
            mprudhom Marc Prud'hommeaux
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment