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

If there are duplicate RexNode in MutableCalc, SubstitutionVisitor should return right rebuild RexNode

    XMLWordPrintableJSON

Details

    Description

      Some user may define some not beautiful mv, but these mv should be worked for rewriting query.
      For example:

        @Test void testMoreSameExprInMv() {
          final String mv = ""
              + "select \"empid\", \"deptno\", sum(\"empid\") as s1, sum(\"empid\") as s2, count(*) as c\n"
              + "from \"emps\" group by \"empid\", \"deptno\"";
          final String query = ""
              +  "select sum(\"empid\"), count(*) from \"emps\" group by \"empid\", \"deptno\"";
          sql(mv, query).ok();
        }
      

      I try debug code to solve this problem.
      I find some bug in

      org.apache.calcite.plan.SubstitutionVisitor#getRexShuttle
      


      PR: https://github.com/apache/calcite/pull/2484
      Please review, THX.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wojustme Xurenhe
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.5h
                  1.5h