xndai commented on a change in pull request #1992:
URL: https://github.com/apache/calcite/pull/1992#discussion_r432262278
##########
File path: core/src/test/java/org/apache/calcite/tools/PlannerTest.java
##########
@@ -988,13 +988,15 @@ private void checkJoinNWay(int n) throws Exception {
+ "left join \"depts\" as d on e.\"deptno\" = d.\"deptno\"\n"
+ "join \"dependents\" as p on e.\"empid\" = p.\"empid\"";
final String expected = ""
- + "EnumerableProject(empid=[$2], deptno=[$3], name=[$4], salary=[$5],
commission=[$6], deptno0=[$7], name0=[$8], employees=[$9], location=[ROW($10,
$11)], empid0=[$0], name1=[$1])\n"
- + " EnumerableHashJoin(condition=[=($0, $2)], joinType=[inner])\n"
- + " EnumerableTableScan(table=[[hr, dependents]])\n"
- + " EnumerableHashJoin(condition=[=($1, $5)], joinType=[left])\n"
- + " EnumerableTableScan(table=[[hr, emps]])\n"
- + " EnumerableProject(deptno=[$0], name=[$1], employees=[$2],
x=[$3.x], y=[$3.y])\n"
- + " EnumerableTableScan(table=[[hr, depts]])";
+ + "EnumerableProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3],
commission=[$4], deptno0=[$5], name0=[$6], employees=[$7], location=[ROW($8,
$9)], empid0=[$10], name1=[$11])\n"
Review comment:
In LoptOptimizeRule, it always swap inputs to make sure smaller input is
on the right side, but this would cause the cost of hash join to increase, so
we end up picking merge join as the best plan. Previously since the row count
of MultiJoin always returns 1 (using the default estimateRowCount()
implementation which is wrong), it was incorrectly treated as smaller input,
and thus generated hash join plan. With this change, the row count is
corrected, but based on the rule behavior and cost model, the best plan now is
merge join plan. If hash join is expected, then the LoptOptimizeRule needs to
be fixed.
The other two plan changes are due to the same issue.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]