Skip to content

Commit 5d377ac

Browse files
committed
Support lambda operator and FILTER() in Snowflake
Fixes #789
1 parent 8672ca4 commit 5d377ac

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/languages/snowflake/snowflake.formatter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ export const snowflake: DialectOptions = {
330330
'=>',
331331
// Assignment https://docs.snowflake.com/en/sql-reference/snowflake-scripting/let
332332
':=',
333+
// Lambda: https://docs.snowflake.com/en/user-guide/querying-semistructured#lambda-expressions
334+
'->',
333335
],
334336
propertyAccessOperators: [':'],
335337
},

src/languages/snowflake/snowflake.functions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export const functions: string[] = [
184184
'EXTRACT',
185185
'EXTRACT_SEMANTIC_CATEGORIES',
186186
'FACTORIAL',
187+
'FILTER',
187188
'FIRST_VALUE',
188189
'FLATTEN',
189190
'FLOOR',

test/snowflake.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,12 @@ describe('SnowflakeFormatter', () => {
204204
items;
205205
`);
206206
});
207+
208+
// Issue #771
209+
it('supports lambda expressions', () => {
210+
expect(format(`SELECT FILTER(my_arr, a -> a:value >= 50);`)).toBe(dedent`
211+
SELECT
212+
FILTER(my_arr, a -> a:value >= 50);
213+
`);
214+
});
207215
});

0 commit comments

Comments
 (0)