Skip to main content

parse_statements_extended

Function parse_statements_extended 

Source
pub fn parse_statements_extended(sql: &str) -> Result<Vec<Statement>>
Expand description

Parse every statement of sql accepting the Spark/Calcite constructs BigQuery lacks, each desugared to plain BigQuery syntax with the same meaning:

  • a LEFT SEMI JOIN b ON c and a LEFT ANTI JOIN b ON c (a one aliased or named factor that has no joins before) become (SELECT * FROM a WHERE [NOT] EXISTS (SELECT 1 FROM b WHERE c)) AS a;
  • (VALUES (1, 2), (3, 4)) AS t(x, y) becomes (SELECT 1 AS x, 2 AS y UNION ALL SELECT 3, 4) AS t (columns without a list are named EXPR$0, EXPR$1, …);
  • SUBSTRING(x FROM a FOR b) becomes SUBSTRING(x, a, b);
  • $ inside identifiers (EXPR$0) and at the start of one ($f1).

Queries BigQuery accepts parse exactly as with parse_statements.