mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
feat: support raw string literal of BigQuery (#812)
* add tests * feat: parse raw literal of bq * merge double quoted & single quoted to raw string literal * Update src/ast/value.rs --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
70917a59ed
commit
58de3c1222
4 changed files with 60 additions and 0 deletions
|
@ -55,6 +55,38 @@ fn parse_byte_literal() {
|
|||
bigquery().one_statement_parses_to(sql, r#"SELECT B'abc', B"abc""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_raw_literal() {
|
||||
let sql = r#"SELECT R'abc', R"abc", R'f\(abc,(.*),def\)', R"f\(abc,(.*),def\)""#;
|
||||
let stmt = bigquery().one_statement_parses_to(
|
||||
sql,
|
||||
r#"SELECT R'abc', R'abc', R'f\(abc,(.*),def\)', R'f\(abc,(.*),def\)'"#,
|
||||
);
|
||||
if let Statement::Query(query) = stmt {
|
||||
if let SetExpr::Select(select) = *query.body {
|
||||
assert_eq!(4, select.projection.len());
|
||||
assert_eq!(
|
||||
&Expr::Value(Value::RawStringLiteral("abc".to_string())),
|
||||
expr_from_projection(&select.projection[0])
|
||||
);
|
||||
assert_eq!(
|
||||
&Expr::Value(Value::RawStringLiteral("abc".to_string())),
|
||||
expr_from_projection(&select.projection[1])
|
||||
);
|
||||
assert_eq!(
|
||||
&Expr::Value(Value::RawStringLiteral(r#"f\(abc,(.*),def\)"#.to_string())),
|
||||
expr_from_projection(&select.projection[2])
|
||||
);
|
||||
assert_eq!(
|
||||
&Expr::Value(Value::RawStringLiteral(r#"f\(abc,(.*),def\)"#.to_string())),
|
||||
expr_from_projection(&select.projection[3])
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
panic!("invalid query")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_table_identifiers() {
|
||||
fn test_table_ident(ident: &str, expected: Vec<Ident>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue