Skip to content

[CALCITE-3584] Support SQL hints propagation for decorrelation#1643

Merged
danny0405 merged 1 commit into
apache:masterfrom
danny0405:CALCITE-3584
Dec 12, 2019
Merged

[CALCITE-3584] Support SQL hints propagation for decorrelation#1643
danny0405 merged 1 commit into
apache:masterfrom
danny0405:CALCITE-3584

Conversation

@danny0405

Copy link
Copy Markdown
Contributor
  • Add a new interface Hintable#setHints(List) to set up the rel node
    hists;
  • Move RelHintPropagateShuttle from SqlToRelConverter to RelOptUtils;
  • Add a new method RelOptUtil#propagateRelHints(RelNode, boolean) to
    support hints for sql-to-rel conversion and decorrelation;
  • Copy the hints for flattened projection in RelStructuredTypeFlattener;
  • Add test cases for hints propagation with decorrelation.

@danny0405
danny0405 force-pushed the CALCITE-3584 branch 2 times, most recently from 0c43a2f to 7260b59 Compare December 11, 2019 02:07

@cshuo cshuo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Danny, nice work. I've left some comments.

</Resource>
<Resource name="hints">
<![CDATA[
Project:[[PROPERTIES inheritPath:[] options:{K1=v1, K2=v2}], [INDEX inheritPath:[] options:[ENAME]], [NO_HASH_JOIN inheritPath:[]]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following is rel plan of the testing sql. I noticed the size of hints for Project 2 is 0. I'm wondering whether there is something wrong with hint propagation in decorrelation part.

LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
  1> LogicalProject(EMPNO=[$0])
    2> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], DEPTNO1=[CAST($11):INTEGER], EXPR$0=[CAST($12):INTEGER])
      LogicalJoin(condition=[AND(=($9, $11), >($5, $12))], joinType=[inner])
        LogicalJoin(condition=[=($7, $9)], joinType=[inner])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
          LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
        LogicalAggregate(group=[{0}], EXPR$0=[AVG($1)])
          3> LogicalProject(DEPTNO=[$7], SAL=[$5])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected, because these 3 hints items are all not belong to the PROJECT node type, so they are all filtered out.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just ignored the definition of hint strategy table...

@cshuo

cshuo commented Dec 11, 2019

Copy link
Copy Markdown

LGTM 👍

* Add a new interface Hintable#withHints(List) to set up the rel node
hints;
* Removes Hintable#mergeHints(List) because it is only a tool method and
i believe that rare cases would need to customize that merging rule;
* Move RelHintPropagateShuttle from SqlToRelConverter to RelOptUtil;
* Add a new method RelOptUtil#propagateRelHints(RelNode, boolean) to
support hints for sql-to-rel conversion and decorrelation;
* Copy the hints for flattened projection in RelStructuredTypeFlattener;
* Add test cases for hints propagation with decorrelation.
@danny0405
danny0405 merged commit 74d0275 into apache:master Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants