Hi Haisheng, Thanks for replying so quickly.
I'm able to find all the columns used in Project expression using RelMetadataQuery.getColumnOrigins, but not sure how to go about other expressions like join, and filter. Example: with t as (select test.colb from test left join test2 on test2.colb = 34) select case colb when 1 then 'one' else 'many' end from t union all select test.cola from test RelMetadataQuery.getColumnOrigins is returning columns test.cola and test.colb, but not test2.colb which is used in join expression. On Thu, 4 Jun, 2020, 7:22 AM Haisheng Yuan, <[email protected]> wrote: > Hi Gaurav, > > You may find this useful: > > https://lists.apache.org/thread.html/rc38d12de860f64e8e2926b7bcf6f2e9e6bcbfbc7ca5e886a71323b47%40%3Cdev.calcite.apache.org%3E > > On 2020/06/04 01:41:41, Gaurav Sehgal <[email protected]> > wrote: > > Hi, > > > > I've a use case where i want to find all the columns, and their > respective > > tables accessed in a sql query. I'm able to find all the table names by > > converting the sql query to RelNode and then visiting the TableScan node > > but not sure what would be the right approach to find all the column > names. > > > > Can someone help me with this? > > > > > > Thanks > > Gaurav Sehgal > > >
