Skip to content

Commit 18b4a14

Browse files
authored
Snowflake - support table function in table factor (regression) (apache#1996)
1 parent 183bc7c commit 18b4a14

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/dialect/snowflake.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ impl Dialect for SnowflakeDialect {
515515
fn is_table_factor(&self, kw: &Keyword, parser: &mut Parser) -> bool {
516516
match kw {
517517
Keyword::LIMIT if peek_for_limit_options(parser) => false,
518+
// Table function
519+
Keyword::TABLE if matches!(parser.peek_token_ref().token, Token::LParen) => true,
518520
_ => !RESERVED_KEYWORDS_FOR_TABLE_FACTOR.contains(kw),
519521
}
520522
}

tests/sqlparser_snowflake.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3609,9 +3609,13 @@ fn test_sql_keywords_as_table_aliases() {
36093609
#[test]
36103610
fn test_sql_keywords_as_table_factor() {
36113611
// LIMIT is a table factor, Snowflake does not reserve it
3612-
snowflake().one_statement_parses_to("SELECT * FROM tbl, LIMIT", "SELECT * FROM tbl, LIMIT");
3612+
snowflake().verified_stmt("SELECT * FROM tbl, LIMIT");
36133613
// LIMIT is not a table factor
36143614
snowflake().one_statement_parses_to("SELECT * FROM tbl, LIMIT 1", "SELECT * FROM tbl LIMIT 1");
3615+
3616+
// Table functions are table factors
3617+
snowflake().verified_stmt("SELECT 1 FROM TABLE(GENERATOR(ROWCOUNT => 10)) AS a, TABLE(GENERATOR(ROWCOUNT => 10)) AS b");
3618+
36153619
// ORDER is reserved
36163620
assert!(snowflake()
36173621
.parse_sql_statements("SELECT * FROM tbl, order")

0 commit comments

Comments
 (0)