Re: Columns used in query

2020-06-04 Thread Haisheng Yuan
Hmm, the getColumnOrigins only gives you output columns, not the used columns. You can follow the example of ColumnOrigins, but for the Join operator, should also process the join conditions. For Filter operator, need to process the filter condition. On 2020/06/04 10:24:55, Gaurav Sehgal wrote:

Re: Columns used in query

2020-06-04 Thread Gaurav Sehgal
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 =

Re: Columns used in query

2020-06-03 Thread Haisheng Yuan
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 wrote: > Hi, > > I've a use case where i want to find all the columns, and their respective >

Columns used in query

2020-06-03 Thread Gaurav Sehgal
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