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

EnumerableUnion should use array comparator when row type is ARRAY

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.10.0
    • Fix Version/s: 1.11.0
    • Component/s: core
    • Labels:
      None
    • Flags:
      Patch

      Description

      Reproduce using cvs adaptor example

      0: jdbc:calcite:model=target/test-classes/mod> select count(*), max(deptno) from emps e1 union select count(*), max(deptno) from emps e2;
      +---------------------+--------+
      |       EXPR$0        | EXPR$1 |
      +---------------------+--------+
      | 5                   | 40     |
      | 5                   | 40     |
      +---------------------+--------+
      

        Activity

        Show
        gaodayue Dayue Gao added a comment - PR: https://github.com/apache/calcite/pull/326
        Hide
        gaodayue Dayue Gao added a comment -

        hold on. intersect and except operator may be also affected.

        Show
        gaodayue Dayue Gao added a comment - hold on. intersect and except operator may be also affected.
        Hide
        julianhyde Julian Hyde added a comment -

        OK, let me know when the PR is ready for review.

        Show
        julianhyde Julian Hyde added a comment - OK, let me know when the PR is ready for review.
        Hide
        gaodayue Dayue Gao added a comment -

        Julian Hyde, I have some problems testing EnumerableIntersect, due to IntersectToDistinctRule.

        I've tried removing it using Hook.PROGRAM, but it doesn't work.

          @Test public void testIntersect() {
            CalciteAssert.hr()
                .query("select \"empid\", \"name\" from \"hr\".\"emps\" where \"deptno\"=10\n"
                    + " intersect \n"
                    + " select \"empid\", \"name\" from \"hr\".\"emps\" where \"empid\">=150")
                .withHook(Hook.PROGRAM, new Function<Pair<List<Prepare.Materialization>, Holder<Program>>,
                    Void>() {
                  public Void apply(Pair<List<Prepare.Materialization>, Holder<Program>> pair) {
                    pair.right.set(new Program() {
                      public RelNode run(RelOptPlanner planner, RelNode rel,
                                         RelTraitSet requiredOutputTraits) {
                        planner.removeRule(IntersectToDistinctRule.INSTANCE);
                        return Programs.standard().run(planner, rel, requiredOutputTraits);
                      }
                    });
                    return null;
                  }
                })
                .explainContains(""
                    + "PLAN=EnumerableIntersect(all=[false])")
                .returns(""
                    + "empid=150; name=Sebastian\n");
          }
        

        Could you give me some suggestions?

        Show
        gaodayue Dayue Gao added a comment - Julian Hyde , I have some problems testing EnumerableIntersect, due to IntersectToDistinctRule. I've tried removing it using Hook.PROGRAM, but it doesn't work. @Test public void testIntersect() { CalciteAssert.hr() .query( "select \" empid\ ", \" name\ " from \" hr\ ".\" emps\ " where \" deptno\ "=10\n" + " intersect \n" + " select \" empid\ ", \" name\ " from \" hr\ ".\" emps\ " where \" empid\ ">=150" ) .withHook(Hook.PROGRAM, new Function<Pair<List<Prepare.Materialization>, Holder<Program>>, Void >() { public Void apply(Pair<List<Prepare.Materialization>, Holder<Program>> pair) { pair.right.set( new Program() { public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits) { planner.removeRule(IntersectToDistinctRule.INSTANCE); return Programs.standard().run(planner, rel, requiredOutputTraits); } }); return null ; } }) .explainContains("" + "PLAN=EnumerableIntersect(all=[ false ])" ) .returns("" + "empid=150; name=Sebastian\n" ); } Could you give me some suggestions?
        Hide
        julianhyde Julian Hyde added a comment -

        The Program.run API is misleading, I'm afraid. I'm not sure that the planning process uses the planner object you have just created (with IntersectToDistinctRule removed). So you'll have to find another way to plan with the rule removed.

        Show
        julianhyde Julian Hyde added a comment - The Program.run API is misleading, I'm afraid. I'm not sure that the planning process uses the planner object you have just created (with IntersectToDistinctRule removed). So you'll have to find another way to plan with the rule removed.
        Hide
        gaodayue Dayue Gao added a comment -

        Julian Hyde PR ready to be review.

        My previous test approach didn't work because after planner.setRoot, PhaseMatchList in RuleQueue is finalized and won't be modified by planner.removeRule.

        To overcome this, I add Hook.PLANNER so that tests can add or remove rules easily.

        Show
        gaodayue Dayue Gao added a comment - Julian Hyde PR ready to be review. My previous test approach didn't work because after planner.setRoot , PhaseMatchList in RuleQueue is finalized and won't be modified by planner.removeRule . To overcome this, I add Hook.PLANNER so that tests can add or remove rules easily.
        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/ce2122ff. Thanks for the PR, Dayue Gao - very nice work!

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/ce2122ff . Thanks for the PR, Dayue Gao - very nice work!
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.11.0 (2017-01-11).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.11.0 (2017-01-11).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            gaodayue Dayue Gao
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development