Re: How to get the used columns (categorized by tables) from a SQL

2020-04-16 Thread XING JIN
You can use SqlValidator.getFieldOrigins for a SqlNode, or use RelMetadataQuery.getColumnOrigins for a RelNode. - Jin Julian Hyde 于2020年4月17日周五 上午7:29写道: > At the RelNode level, you can use RelMetadataQuery.getColumnOrigins. > > But I’m sure that there’s something available at the SqlNode

Re: How to get the used columns (categorized by tables) from a SQL

2020-04-16 Thread Julian Hyde
At the RelNode level, you can use RelMetadataQuery.getColumnOrigins. But I’m sure that there’s something available at the SqlNode level, after validation. PreparedExplain.getFieldOrigins() is what the JDBC driver uses to provide ResultSetMetadata.getColumnName(int) etc. Julian > On Apr 16,

Re: How to get the used columns (categorized by tables) from a SQL

2020-04-16 Thread Feng Zhu
You can customize a RelVisitor to visit the RelNode, and collect the columns from TableScan's rowtype. 王驰 于2020年4月16日周四 下午11:23写道: > Hi folks, > > > We're using CalCite in our project for SQL parsing and validating. We have > a question: is there any way to get all used columns from a SQL? > >

How to get the used columns (categorized by tables) from a SQL

2020-04-16 Thread 王驰
Hi folks, We're using CalCite in our project for SQL parsing and validating. We have a question: is there any way to get all used columns from a SQL? Consider the following case: we have two tables `user` and `user_region`. And the SQL is like ``` SELECT id, name, age, country,