You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by weijie tong <to...@gmail.com> on 2017/03/17 08:07:28 UTC

How to find the correct joint key names ?

    I have a requirement to find the on condition name of a join clause,
but while the condition columns from two tables are the same ,I can not
find the exact join column name.
    For example : select col1 , col2 from table1 a join table2 b on a.colo
= b.colo . When I apply a rule using HepPlanner, I want to find the
condition names from both tables ,i.e. : colo and another colo , using the
codes : joinRel.getRowType().getFieldList().get(index).getName() ,the index
parameter was got from the condition method,the joinRel was the matched
join RelNode. The reust is : colo and colo0 . As you see , the second joint
key has a zero postfix.
  I want to know how to find the correct joint column names at this case?

Re: How to find the correct joint key names ?

Posted by weijie tong <to...@gmail.com>.
@Jess thanks for your enthusiastic and valuable hint ,I have solved it.

On Sat, Mar 18, 2017 at 8:08 AM, Jess Balint <jb...@gmail.com> wrote:

> Try RelMetadataQuery.getColumnOrigin()
>
> Jess
>
> On Fri, Mar 17, 2017 at 3:07 AM, weijie tong <to...@gmail.com>
> wrote:
>
> >     I have a requirement to find the on condition name of a join clause,
> > but while the condition columns from two tables are the same ,I can not
> > find the exact join column name.
> >     For example : select col1 , col2 from table1 a join table2 b on
> a.colo
> > = b.colo . When I apply a rule using HepPlanner, I want to find the
> > condition names from both tables ,i.e. : colo and another colo , using
> the
> > codes : joinRel.getRowType().getFieldList().get(index).getName() ,the
> > index
> > parameter was got from the condition method,the joinRel was the matched
> > join RelNode. The reust is : colo and colo0 . As you see , the second
> joint
> > key has a zero postfix.
> >   I want to know how to find the correct joint column names at this case?
> >
>

Re: How to find the correct joint key names ?

Posted by Jess Balint <jb...@gmail.com>.
Try RelMetadataQuery.getColumnOrigin()

Jess

On Fri, Mar 17, 2017 at 3:07 AM, weijie tong <to...@gmail.com>
wrote:

>     I have a requirement to find the on condition name of a join clause,
> but while the condition columns from two tables are the same ,I can not
> find the exact join column name.
>     For example : select col1 , col2 from table1 a join table2 b on a.colo
> = b.colo . When I apply a rule using HepPlanner, I want to find the
> condition names from both tables ,i.e. : colo and another colo , using the
> codes : joinRel.getRowType().getFieldList().get(index).getName() ,the
> index
> parameter was got from the condition method,the joinRel was the matched
> join RelNode. The reust is : colo and colo0 . As you see , the second joint
> key has a zero postfix.
>   I want to know how to find the correct joint column names at this case?
>