Skip to content

Commit 800c0c4

Browse files
committed
Fix(snowflake): emit proper HANDLER property syntax
1 parent c507574 commit 800c0c4

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

sqlglot/generators/snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ class SnowflakeGenerator(generator.Generator):
481481
),
482482
exp.CosineDistance: rename_func("VECTOR_COSINE_SIMILARITY"),
483483
exp.EuclideanDistance: rename_func("VECTOR_L2_DISTANCE"),
484+
exp.HandlerProperty: lambda self, e: f"HANDLER = {self.sql(e, 'this')}",
484485
exp.FileFormatProperty: lambda self, e: (
485486
f"FILE_FORMAT=({self.expressions(e, 'expressions', sep=' ')})"
486487
),

tests/dialects/test_snowflake.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4419,6 +4419,10 @@ def test_user_defined_functions(self):
44194419
},
44204420
)
44214421

4422+
self.validate_identity(
4423+
"CREATE OR REPLACE FUNCTION repro_fn() RETURNS INT LANGUAGE PYTHON HANDLER = 'fn' RUNTIME_VERSION='3.11' PACKAGES=() AS '\\ndef fn():\\n return 1\\n'"
4424+
)
4425+
44224426
def test_stored_procedures(self):
44234427
self.validate_identity("CALL a.b.c(x, y)", check_command_warning=True)
44244428
self.validate_identity(

0 commit comments

Comments
 (0)