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

DISTINCT applied to VALUES returns wrong result

    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

          People

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

            Dates

              Created:
              Updated:
              Resolved: