mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Align Snowflake dialect to new test of reserved keywords (#1924)
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
d2466af20a
commit
ed8757f2f0
2 changed files with 31 additions and 4 deletions
|
@ -301,9 +301,8 @@ impl Dialect for SnowflakeDialect {
|
|||
true
|
||||
}
|
||||
|
||||
fn is_select_item_alias(&self, explicit: bool, kw: &Keyword, parser: &mut Parser) -> bool {
|
||||
explicit
|
||||
|| match kw {
|
||||
fn is_column_alias(&self, kw: &Keyword, parser: &mut Parser) -> bool {
|
||||
match kw {
|
||||
// The following keywords can be considered an alias as long as
|
||||
// they are not followed by other tokens that may change their meaning
|
||||
// e.g. `SELECT * EXCEPT (col1) FROM tbl`
|
||||
|
|
|
@ -3415,10 +3415,38 @@ fn parse_ls_and_rm() {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sql_keywords_as_select_item_ident() {
|
||||
// Some keywords that should be parsed as an alias
|
||||
let unreserved_kws = vec!["CLUSTER", "FETCH", "RETURNING", "LIMIT", "EXCEPT", "SORT"];
|
||||
for kw in unreserved_kws {
|
||||
snowflake().verified_stmt(&format!("SELECT 1, {kw}"));
|
||||
}
|
||||
|
||||
// Some keywords that should not be parsed as an alias
|
||||
let reserved_kws = vec![
|
||||
"FROM",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"INTERSECT",
|
||||
"INTO",
|
||||
"ORDER",
|
||||
"SELECT",
|
||||
"UNION",
|
||||
"WHERE",
|
||||
"WITH",
|
||||
];
|
||||
for kw in reserved_kws {
|
||||
assert!(snowflake()
|
||||
.parse_sql_statements(&format!("SELECT 1, {kw}"))
|
||||
.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sql_keywords_as_select_item_aliases() {
|
||||
// Some keywords that should be parsed as an alias
|
||||
let unreserved_kws = vec!["CLUSTER", "FETCH", "RETURNING", "LIMIT", "EXCEPT"];
|
||||
let unreserved_kws = vec!["CLUSTER", "FETCH", "RETURNING", "LIMIT", "EXCEPT", "SORT"];
|
||||
for kw in unreserved_kws {
|
||||
snowflake()
|
||||
.one_statement_parses_to(&format!("SELECT 1 {kw}"), &format!("SELECT 1 AS {kw}"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue