Skip to content

Commit 8d7c62a

Browse files
tomershaniiiayman-sigma
authored andcommitted
Snowflake - support table function in table factor (regression) (apache#1996)
1 parent fd39a48 commit 8d7c62a

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
@@ -3628,9 +3628,13 @@ fn test_sql_keywords_as_table_aliases() {
36283628
#[test]
36293629
fn test_sql_keywords_as_table_factor() {
36303630
// LIMIT is a table factor, Snowflake does not reserve it
3631-
snowflake().one_statement_parses_to("SELECT * FROM tbl, LIMIT", "SELECT * FROM tbl, LIMIT");
3631+
snowflake().verified_stmt("SELECT * FROM tbl, LIMIT");
36323632
// LIMIT is not a table factor
36333633
snowflake().one_statement_parses_to("SELECT * FROM tbl, LIMIT 1", "SELECT * FROM tbl LIMIT 1");
3634+
3635+
// Table functions are table factors
3636+
snowflake().verified_stmt("SELECT 1 FROM TABLE(GENERATOR(ROWCOUNT => 10)) AS a, TABLE(GENERATOR(ROWCOUNT => 10)) AS b");
3637+
36343638
// ORDER is reserved
36353639
assert!(snowflake()
36363640
.parse_sql_statements("SELECT * FROM tbl, order")

0 commit comments

Comments
 (0)