Skip to content

Do not parse ASOF and MATCH_CONDITION as table factor aliases #1698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2025
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/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ pub const RESERVED_FOR_TABLE_ALIAS: &[Keyword] = &[
Keyword::ANTI,
Keyword::SEMI,
Keyword::RETURNING,
Keyword::ASOF,
Keyword::MATCH_CONDITION,
// for MSSQL-specific OUTER APPLY (seems reserved in most dialects)
Keyword::OUTER,
Keyword::SET,
Expand Down
14 changes: 14 additions & 0 deletions tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,20 @@ fn asof_joins() {
"ON s.state = p.state ",
"ORDER BY s.observed",
));

// Test without explicit aliases
#[rustfmt::skip]
snowflake_and_generic().verified_query(concat!(
"SELECT * ",
"FROM snowtime ",
"ASOF JOIN raintime ",
"MATCH_CONDITION (snowtime.observed >= raintime.observed) ",
"ON snowtime.state = raintime.state ",
"ASOF JOIN preciptime ",
"MATCH_CONDITION (showtime.observed >= preciptime.observed) ",
"ON showtime.state = preciptime.state ",
"ORDER BY showtime.observed",
));
}

#[test]
Expand Down