Snowflake - support table function in table factor (regression) (#1996)

This commit is contained in:
tomershaniii 2025-08-08 12:22:30 +03:00 committed by GitHub
parent 183bc7c5ff
commit 18b4a14e0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -515,6 +515,8 @@ impl Dialect for SnowflakeDialect {
fn is_table_factor(&self, kw: &Keyword, parser: &mut Parser) -> bool {
match kw {
Keyword::LIMIT if peek_for_limit_options(parser) => false,
// Table function
Keyword::TABLE if matches!(parser.peek_token_ref().token, Token::LParen) => true,
_ => !RESERVED_KEYWORDS_FOR_TABLE_FACTOR.contains(kw),
}
}

View file

@ -3609,9 +3609,13 @@ fn test_sql_keywords_as_table_aliases() {
#[test]
fn test_sql_keywords_as_table_factor() {
// LIMIT is a table factor, Snowflake does not reserve it
snowflake().one_statement_parses_to("SELECT * FROM tbl, LIMIT", "SELECT * FROM tbl, LIMIT");
snowflake().verified_stmt("SELECT * FROM tbl, LIMIT");
// LIMIT is not a table factor
snowflake().one_statement_parses_to("SELECT * FROM tbl, LIMIT 1", "SELECT * FROM tbl LIMIT 1");
// Table functions are table factors
snowflake().verified_stmt("SELECT 1 FROM TABLE(GENERATOR(ROWCOUNT => 10)) AS a, TABLE(GENERATOR(ROWCOUNT => 10)) AS b");
// ORDER is reserved
assert!(snowflake()
.parse_sql_statements("SELECT * FROM tbl, order")