JDBC table names and column names are of limited use. They tell you where a 
particular column comes from, and your “a” column does not come (directly) from 
a table. I think you’ll find that Calcite is implementing the JDBC standard 
correctly, and is consistent with other databases. 

What do you need the table name for?

If you want to understand the structure of the query - e.g. the fact that the 
query is sourced from the “test” table - then your might be better working with 
the SqlNode or RelNode representations. The RelNode representation of your 
query is


  Aggregate(count(*) as a)
             ^
              |
  TableScan(“test”)

and that probably tells you what you need to know.

Julian


> On Jan 5, 2020, at 11:42 PM, Juan Pan <[email protected]> wrote:
> 
> 
> 
> Hi Calcite Community,
> 
> 
> Thanks for your attention. After failing self-helping by debug source code, i 
> sent this email for your help. :)
> 
> 
> My query SQL is `SELECT count(*) a FROM test`, and i called JDBC interface, 
> i.e, `ResultSet.getMetaData().getTableName(1)` to get table name, i.e, test, 
> however the result of which is null.
> I traced the process and found that if !(selectItem instanceof SqlIdentifier) 
> then return null in `SqlValidatorImpl.java`. Is there any way to get the real 
> table name, i.e, test?
> 
> 
> Thanks in advance,
> 
> 
> Trista
> 
> 
> 
> 
> 
> 
> Juan Pan (Trista) 
> 
> Senior DBA & PPMC of Apache ShardingSphere(Incubating)
> E-mail: [email protected]
> 
> 
> 

Reply via email to