mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-01 19:57:30 +00:00
BigQuery support inline comment with hash syntax (#1192)
This commit is contained in:
parent
23103302e6
commit
732e1ec1fc
2 changed files with 19 additions and 1 deletions
|
@ -984,7 +984,7 @@ impl<'a> Tokenizer<'a> {
|
||||||
}
|
}
|
||||||
'{' => self.consume_and_return(chars, Token::LBrace),
|
'{' => self.consume_and_return(chars, Token::LBrace),
|
||||||
'}' => self.consume_and_return(chars, Token::RBrace),
|
'}' => self.consume_and_return(chars, Token::RBrace),
|
||||||
'#' if dialect_of!(self is SnowflakeDialect) => {
|
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect) => {
|
||||||
chars.next(); // consume the '#', starting a snowflake single-line comment
|
chars.next(); // consume the '#', starting a snowflake single-line comment
|
||||||
let comment = self.tokenize_single_line_comment(chars);
|
let comment = self.tokenize_single_line_comment(chars);
|
||||||
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {
|
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {
|
||||||
|
|
|
@ -8607,6 +8607,24 @@ fn test_release_savepoint() {
|
||||||
one_statement_parses_to("RELEASE test1", "RELEASE SAVEPOINT test1");
|
one_statement_parses_to("RELEASE test1", "RELEASE SAVEPOINT test1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_comment_hash_syntax() {
|
||||||
|
let dialects = TestedDialects {
|
||||||
|
dialects: vec![Box::new(BigQueryDialect {}), Box::new(SnowflakeDialect {})],
|
||||||
|
options: None,
|
||||||
|
};
|
||||||
|
let sql = r#"
|
||||||
|
# comment
|
||||||
|
SELECT a, b, c # , d, e
|
||||||
|
FROM T
|
||||||
|
####### comment #################
|
||||||
|
WHERE true
|
||||||
|
# comment
|
||||||
|
"#;
|
||||||
|
let canonical = "SELECT a, b, c FROM T WHERE true";
|
||||||
|
dialects.verified_only_select_with_canonical(sql, canonical);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_buffer_reuse() {
|
fn test_buffer_reuse() {
|
||||||
let d = GenericDialect {};
|
let d = GenericDialect {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue