Skip to content

Commit

Permalink
Support lambda operator and FILTER() in Snowflake
Browse files Browse the repository at this point in the history
Fixes #789
  • Loading branch information
nene committed Oct 21, 2024
1 parent 8672ca4 commit 5d377ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/languages/snowflake/snowflake.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ export const snowflake: DialectOptions = {
'=>',
// Assignment https://docs.snowflake.com/en/sql-reference/snowflake-scripting/let
':=',
// Lambda: https://docs.snowflake.com/en/user-guide/querying-semistructured#lambda-expressions
'->',
],
propertyAccessOperators: [':'],
},
Expand Down
1 change: 1 addition & 0 deletions src/languages/snowflake/snowflake.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export const functions: string[] = [
'EXTRACT',
'EXTRACT_SEMANTIC_CATEGORIES',
'FACTORIAL',
'FILTER',
'FIRST_VALUE',
'FLATTEN',
'FLOOR',
Expand Down
8 changes: 8 additions & 0 deletions test/snowflake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,12 @@ describe('SnowflakeFormatter', () => {
items;
`);
});

// Issue #771
it('supports lambda expressions', () => {
expect(format(`SELECT FILTER(my_arr, a -> a:value >= 50);`)).toBe(dedent`
SELECT
FILTER(my_arr, a -> a:value >= 50);
`);
});
});

0 comments on commit 5d377ac

Please sign in to comment.