Hi Thomas, FYI,AggregateJoinRemoveRule is an independent rule, now it is not added anywhere, so for your scenario, this rule does not take effect.
A good way to learn Calcite is to look at the various unit tests inside Calcite, such as the planner rule unit test `RelOptRulesTest.java`, which you can debug yourself and use `RelOptRulesTest.xml` to see the changes before and after the plan. Best, LakeShen Thomas Rynne <[email protected]> 于2023年10月13日周五 01:39写道: > Hi, I am trying to get a better understanding of calcite. > > I tried running the JdbcExample* using calcite 1.35.0 but with this query: > > explain plan for > select distinct \"cust_id\" > from "foodmart"."sales_fact_1997" as s > left join "hr"."emps" as e on e."empid" = s."cust_id" > > The output is > EnumerableAggregate(group=[{0}]) > EnumerableMergeJoin(condition=[=($0, $1)], joinType=[left]) > EnumerableSort(sort0=[$0], dir0=[ASC]) > EnumerableCalc(expr#0..1=[{inputs}], cust_id=[$t0]) > EnumerableTableScan(table=[[foodmart, sales_fact_1997]]) > EnumerableSort(sort0=[$0], dir0=[ASC]) > EnumerableCalc(expr#0..1=[{inputs}], empid=[$t0]) > EnumerableTableScan(table=[[hr, emps]]) > > I was expecting AggregateJoinRemoveRule to remove the join and the scan of > emps. > > Is this just a bug or do I need to run calcite in a different way? > > thanks for any help, > Thomas > > * > https://github.com/apache/calcite/blob/main/core/src/test/java/org/apache/calcite/examples/foodmart/java/JdbcExample.java > >
