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

Improved LogicalPlan representation of distinct keyword

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 1.36.0
    • 1.37.0
    • core
    • None

    Description

      In the ToLogicalConvert test, the LogicalPlan parsed with or without the distinct keyword is the same. I think this is an improvement.

       

      @Test void testdistnct() {
        // Equivalent SQL:
        //   SELECT DISTINCT *
        //   FROM emp
        final RelBuilder builder = builder();
        final RelNode rel =
            builder.scan("EMP")
                .distinct()
                .build();
        String expectedPhysical = ""
            + "EnumerableTableScan(table=[[scott, EMP]])\n";
        String expectedLogical = ""
            + "LogicalTableScan(table=[[scott, EMP]])\n";
        verify(rel, expectedPhysical, expectedLogical);
      }
      
      @Test void test() {
        // Equivalent SQL:
        //   SELECT DISTINCT *
        //   FROM emp
        final RelBuilder builder = builder();
        final RelNode rel =
            builder.scan("EMP")
                .build();
        String expectedPhysical = ""
            + "EnumerableTableScan(table=[[scott, EMP]])\n";
        String expectedLogical = ""
            + "LogicalTableScan(table=[[scott, EMP]])\n";
        verify(rel, expectedPhysical, expectedLogical);
      } 

      I think it can be improved to something like

      Logical Project (DISTINCT)
      +- Logical Scan (Table: employees)

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              caicancai Caican Cai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: