mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-01 04:32:16 +00:00
fix: begin statement for bigquery (#1975)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
This commit is contained in:
parent
145922affe
commit
865c191a53
2 changed files with 18 additions and 0 deletions
|
@ -19,6 +19,7 @@ use crate::ast::Statement;
|
|||
use crate::dialect::Dialect;
|
||||
use crate::keywords::Keyword;
|
||||
use crate::parser::{Parser, ParserError};
|
||||
use crate::tokenizer::Token;
|
||||
|
||||
/// These keywords are disallowed as column identifiers. Such that
|
||||
/// `SELECT 5 AS <col> FROM T` is rejected by BigQuery.
|
||||
|
@ -47,6 +48,13 @@ pub struct BigQueryDialect;
|
|||
impl Dialect for BigQueryDialect {
|
||||
fn parse_statement(&self, parser: &mut Parser) -> Option<Result<Statement, ParserError>> {
|
||||
if parser.parse_keyword(Keyword::BEGIN) {
|
||||
if parser.peek_keyword(Keyword::TRANSACTION)
|
||||
|| parser.peek_token_ref().token == Token::SemiColon
|
||||
|| parser.peek_token_ref().token == Token::EOF
|
||||
{
|
||||
parser.prev_token();
|
||||
return None;
|
||||
}
|
||||
return Some(parser.parse_begin_exception_end());
|
||||
}
|
||||
|
||||
|
|
|
@ -2566,3 +2566,13 @@ fn test_struct_trailing_and_nested_bracket() {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_begin_transaction() {
|
||||
bigquery().verified_stmt("BEGIN TRANSACTION");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_begin_statement() {
|
||||
bigquery().verified_stmt("BEGIN");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue