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

DISTINCT applied to VALUES returns wrong result

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.14.0
    • Fix Version/s: 1.16.0
    • Component/s: None
    • Labels:
      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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: