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

RelFieldTrimmer loses hints

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      The trimmed plan generated by RelFieldTrimmer can lose the hints that might be present in the input plan.
      The issue can be reproduced with the following test (to be added to RelFieldTrimmerTest):

        @Test void testJoinWithHints() {
          final RelHint noHashJoinHint = RelHint.builder("NO_HASH_JOIN").inheritPath(0).build();
          final RelBuilder builder = RelBuilder.create(config().build());
          final RelNode original =
              builder.scan("EMP")
                  .scan("DEPT")
                  .join(JoinRelType.INNER,
                      builder.equals(
                          builder.field(2, 0, "DEPTNO"),
                          builder.field(2, 1, "DEPTNO")))
                  .hints(noHashJoinHint)
                  .project(
                      builder.field("ENAME"),
                      builder.field("DNAME"))
                  .build();
      
          final RelFieldTrimmer fieldTrimmer = new RelFieldTrimmer(null, builder);
          final RelNode trimmed = fieldTrimmer.trim(original);
      
          final String expected = ""
              + "LogicalProject(ENAME=[$1], DNAME=[$4])\n"
              + "  LogicalJoin(condition=[=($2, $3)], joinType=[inner])\n"
              + "    LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7])\n"
              + "      LogicalTableScan(table=[[scott, EMP]])\n"
              + "    LogicalProject(DEPTNO=[$0], DNAME=[$1])\n"
              + "      LogicalTableScan(table=[[scott, DEPT]])\n";
          assertThat(trimmed, hasTree(expected));
      
          assertTrue(original.getInput(0) instanceof Join);
          final Join originalJoin = (Join) original.getInput(0);
          assertTrue(originalJoin.getHints().contains(noHashJoinHint));
      
          assertTrue(trimmed.getInput(0) instanceof Join);
          final Join join = (Join) trimmed.getInput(0);
          assertTrue(join.getHints().contains(noHashJoinHint));
        }
      

      which fails in the last line: assertTrue(join.getHints().contains(noHashJoinHint));

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rubenql Ruben Q L
            rubenql Ruben Q L
            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 - 2h
                2h

                Slack

                  Issue deployment