Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down
6 changes: 5 additions & 1 deletion tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down