Hi Yanjing, I found a discussion in the ML suggesting to use RelOptUtil#findAllTables to get all tables involved in a query: https://lists.apache.org/thread/wcfv2bhdytwsoyc3qlsnxcd7nmnnlb06
Can you check if that's what you want? Best regards, Alessandro On Wed, 13 Apr 2022 at 09:33, Yanjing Wang <zhuangzixiao...@gmail.com> wrote: > Hi Commnunity, > > In real scenarios, many developers want to get what tables a query > statement contains. > > such as 'WITH t as (SELECT * FROM t1) SELECT * FROM t, t2', it only > contains table t1 and t2. > > I tried to visit the SqlNode and found this solution is very complicated > and has very many checks, otherwise easy to get in parser. > such as add one line 'involvedTables.add(nameList);' in > 'CompoundTableIdentifier' production rule. > > I know that this isn't the duty of parser, but I think it's the easiest way > to get the tables, I want to add this functionality to parser, how do you > think? >