google / zetasql

ZetaSQL - Analyzer Framework for SQL
Apache License 2.0
2.28k stars 214 forks source link

ResolvedStatement - ResolvedTableScan not getting the full table name due to backtick placement #126

Open leoch20 opened 1 year ago

leoch20 commented 1 year ago

Hello,

I implemented sub catalogs as recommended here https://github.com/google/zetasql/issues/125 to analyze queries with different table names backtick placements.

While looking to extract the columns, along with their table, from a query the ResolvedNodes.Visitor() does not return the fully qualified table name:

select col from `some-project`.ds.table_name  

.getFullName() returns table_name.

Is there a way to get the project and dataset?


Here is my visitor in scala

    statement.accept(new ResolvedNodes.Visitor() {
      override def visit(node: ResolvedNodes.ResolvedTableScan): Unit = {
        val table = node.getTable
        table.getColumnList.forEach(col => (table.getFullName, col.getName))
        super.visit(node)
      }
    })