Skip to content

Commit

Permalink
snowflake/generic: position can be the name of a column (apache#1022)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Stefaniak <[email protected]>
  • Loading branch information
2 people authored and serprex committed Nov 6, 2023
1 parent 7db5d9f commit 3f3b6f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,9 @@ impl<'a> Parser<'a> {
Keyword::EXTRACT => self.parse_extract_expr(),
Keyword::CEIL => self.parse_ceil_floor_expr(true),
Keyword::FLOOR => self.parse_ceil_floor_expr(false),
Keyword::POSITION => self.parse_position_expr(),
Keyword::POSITION if self.peek_token().token == Token::LParen => {
self.parse_position_expr()
}
Keyword::SUBSTRING => self.parse_substring_expr(),
Keyword::OVERLAY => self.parse_overlay_expr(),
Keyword::TRIM => self.parse_trim_expr(),
Expand Down
6 changes: 6 additions & 0 deletions tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,12 @@ fn test_snowflake_trim() {
);
}

#[test]
fn parse_position_not_function_columns() {
snowflake_and_generic()
.verified_stmt("SELECT position FROM tbl1 WHERE position NOT IN ('first', 'last')");
}

#[test]
fn parse_subquery_function_argument() {
// Snowflake allows passing an unparenthesized subquery as the single
Expand Down

0 comments on commit 3f3b6f4

Please sign in to comment.