diff --git a/src/dialect/bigquery.rs b/src/dialect/bigquery.rs index 544be23e0..d34be9a40 100644 --- a/src/dialect/bigquery.rs +++ b/src/dialect/bigquery.rs @@ -136,6 +136,14 @@ impl Dialect for BigQueryDialect { true } + /// BigQuery allows a query to start with `FROM` (e.g. `FROM t`, and the + /// entry form for pipe syntax, `FROM t |> ...`). + /// + /// See + fn supports_from_first_select(&self) -> bool { + true + } + /// See fn supports_execute_immediate(&self) -> bool { true diff --git a/tests/sqlparser_bigquery.rs b/tests/sqlparser_bigquery.rs index f6d4483c2..97f71cfe7 100644 --- a/tests/sqlparser_bigquery.rs +++ b/tests/sqlparser_bigquery.rs @@ -2950,3 +2950,10 @@ fn test_create_snapshot_table() { "CREATE SNAPSHOT TABLE IF NOT EXISTS dataset_id.table1 CLONE dataset_id.table2 FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR) OPTIONS(expiration_timestamp = TIMESTAMP '2025-01-01 00:00:00 UTC')", ); } + +#[test] +fn parse_from_first_select() { + bigquery().verified_stmt("FROM t"); + bigquery().verified_stmt("FROM t SELECT a, b"); + bigquery().verified_stmt("FROM t |> WHERE a > 1 |> SELECT a"); +}