-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
build_scope does not include the target table of a CREATE TABLE AS SELECT statement. sqlglot includes it.
sqlglot
# /// script
# requires-python = ">=3.11"
# dependencies = ["sqlglot"]
# ///
from sqlglot import exp, parse
sql = "CREATE TABLE out_table AS SELECT 1 AS id"
tables = [t.name for stmt in parse(sql, dialect="bigquery") for t in stmt.find_all(exp.Table)]
print(f"SQL: {sql}")
print(f"Tables: {tables}")polyglot repro
use polyglot_sql::{self as pgsql, DialectType};
fn main() {
let sql = "CREATE TABLE out_table AS SELECT 1 AS id";
let expr = &pgsql::parse(sql, DialectType::BigQuery).unwrap()[0];
let scope = pgsql::scope::build_scope(expr);
let tables: Vec<&String> = scope.sources.keys().collect();
println!("SQL: {}", sql);
println!("Tables: {:?}", tables);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels