Skip to content

BigQuery partitioning, clustering, options fail hard #34

@MartinSahlen

Description

@MartinSahlen

A totally normal query like this simple example

use polyglot_sql::{DialectType, parse_one};

fn main() {
    const query: &str = r#"
   create or replace table `p1`.`d1`.`t1`

    partition by date_trunc(day, month)
    cluster by some_cluster_column

    OPTIONS(
      description="""""",

      labels=[('l1', 'v'), ('l2', 'v2'), ('l3', 'v3'), ('l4', 'v5')]
    )
    as (SELECT current_date as day, DATE_TRUNC(current_date(), month) as month, 'c' as some_cluster_column)
 "#;

    let rest = parse_one(query, DialectType::BigQuery).unwrap();
}

yields

thread 'main' (38353401) panicked at src/main.rs:18:56:
called `Result::unwrap()` on an `Err` value: Parse { message: "Expected LParen, got Partition ('partition') near [d1.t1     partition by date_trunc(]", line: 4, column: 14 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I have not dived deep into the code, but feels like this could be needing quite extensive review of https://docs.cloud.google.com/bigquery/docs/creating-partitioned-tables and creating/updating tables. This is a simplified real world example. it works fine in sqlparser-rs and runs fine in BigQuery editor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions