You need to do this on a SqlNode tree that has passed validation
(using the state in the validator). If you did it earlier, i.e. on a
SqlNode tree, identifiers have not been resolved to tables; if you did
it later, i.e. on a RelNode tree, then views would have been expanded.

After validation, SqlValidatorImpl.namespaces.values() probably
contains what you need. It would be great if you would add a method

  List<SqlMoniker> SqlValidator.getTablesReferenced()

and a few unit tests and contribute it.

If you don't want to explicitly build a list, you might try changing
SqlValidatorTable.getAllowedAccess() on your tables. Then
SqlValidatorImpl.validateAccess will throw when it is called during
validation. Again, if you use this, please contribute some unit tests;
the functionality is old and there are no longer tests for it.

Julian



On Thu, Oct 5, 2017 at 7:32 PM, Homer <[email protected]> wrote:
> Hello,
>
> I am currently trying to gather table and view information out of Calcite
> for security checking access.
>
> I am currently finding it is quite complicated to process through a complex
> query to get all the tables and views in use.
>
> I am processing through the SqlNode returned by the equivalent of
> planner.parse(sql_query_text).
>
> I need to do it here prior to expansion of views as I need to know it was a
> view not the full table in use.
>
> I just want to check if there is a better way to get this information?
>
> thanks
>

Reply via email to