Skip to content

Commit 41e78a0

Browse files
committed
review
1 parent 373219f commit 41e78a0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/tokenizer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use serde::{Deserialize, Serialize};
3535
use sqlparser_derive::{Visit, VisitMut};
3636

3737
use crate::ast::DollarQuotedString;
38-
use crate::dialect::SnowflakeDialect;
38+
use crate::dialect::{BigQueryDialect, GenericDialect, SnowflakeDialect};
3939
use crate::dialect::{Dialect, MySqlDialect};
4040
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
4141

@@ -507,7 +507,7 @@ impl<'a> Tokenizer<'a> {
507507
Ok(Some(Token::Whitespace(Whitespace::Newline)))
508508
}
509509
// BigQuery uses b or B for byte string literal
510-
b @ 'B' | b @ 'b' => {
510+
b @ 'B' | b @ 'b' if dialect_of!(self is BigQueryDialect | GenericDialect) => {
511511
chars.next(); // consume
512512
match chars.peek() {
513513
Some('\'') => {

tests/sqlparser_bigquery.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ fn parse_byte_literal() {
4545
&Expr::Value(Value::DoubleQuotedByteStringLiteral("abc".to_string())),
4646
expr_from_projection(&select.projection[1])
4747
);
48+
49+
let sql = r#"SELECT b'abc', b"abc""#;
50+
bigquery().one_statement_parses_to(sql, r#"SELECT B'abc', B"abc""#);
4851
}
4952

5053
#[test]

0 commit comments

Comments
 (0)