It would be called only when it's needed, not *every time*, it depends on what SQL statement you are validating. If your Sql statement contains a table reference which needs to be resolved by the Schema, it will be called[1].
[1] https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/validate/SchemaNamespace.java Thomas Wang <[email protected]> 于2022年12月26日周一 21:00写道: > Thanks Benchao. You meant Schema#getTableNames is called *every time* when > a SQL statement is being validated? > > The reason why I'm asking is because I want to build a service and am > wondering if I can reuse schema objects. > > Thanks. > > Thomas > > On Mon, Dec 26, 2022 at 3:26 AM Benchao Li <[email protected]> wrote: > > > Hi Thomas, > > > > Schema#getTableNames is mainly used in SQL validating phase. You do not > > need to call it manually. > > > > Thomas Wang <[email protected]> 于2022年12月26日周一 11:08写道: > > > > > Hi Calcite community: > > > > > > I see in the code that JdbcSchema.getTable(String name) is using a > local > > > cached variable tableMap. I'm wondering under what circumstances, this > > > local variable gets refreshed? Based on the code comment, it seems the > > > variable is refreshed when Jdbc.getTableNames() is called, but I didn't > > > find anywhere in the codebase where JdbcSchema.getTableNames() is > called. > > > Do I need to manually call this method to refresh? Thanks. > > > > > > Thomas > > > > > > > > > -- > > > > Best, > > Benchao Li > > > -- Best, Benchao Li
