Hi

org.apache.calcite.rel.metadata.RelMetadataQuery#getColumnOrigins may help

Regards!

Aron Tao


James Daniel <[email protected]> 于2021年5月19日周三 上午12:35写道:

> Hi, all.
> I am trying to rewrite the query plan by removing some nodes but faced with
> issues related to manipulating column ref indexes.
>
> Let's consider the following calcite plan:
>
>   LogicalProject([...])
>     LogicalJoin(condition=[=($0, $4)], joinType=[inner])
>       LogicalTableScan(table=[[DB, R]])
>       LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
>         LogicalProject(a=[$3], $f0=[true])
>           LogicalTableScan(table=[[DB, S]])
>
>
> In the join condition =($0, $4), the RHS column ref $4 is actually coming
> from the $3 of table S.
> To know this, we track down few nodes in the tree starting from the RHS
> child of the join node.
> But it becomes tricky when we use a more complex situation.
> 1) So, I wonder is there a utility class or method to support this purpose?
>
> Furthermore, when we remove LogicalProject(a=[$3], $f0=[true]), we have to
> manipulate all related column ref index starting from a parent of that
> project node to the root node but manually tracking and shifting column ref
> index is really a matter due to its complexity.
> 2) So I wonder the current Calcite impl has a utility class or methods to
> help this situation.
>
> 3) Also, would you give me some general guidelines for implementing this
> kind of stuff in Calcite?
>
> Thanks,
> James
>

Reply via email to