Skip to content

Commit

Permalink
Fix(snowflake): ensure OBJECT_CONSTRUCT is not generated inside of VA…
Browse files Browse the repository at this point in the history
…LUES (#3419)
  • Loading branch information
georgesittas authored May 7, 2024
1 parent 17c31da commit ea197ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sqlglot/dialects/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,10 @@ class Generator(generator.Generator):
}

UNSUPPORTED_VALUES_EXPRESSIONS = {
exp.Map,
exp.StarMap,
exp.Struct,
exp.VarMap,
}

def values_sql(self, expression: exp.Values, values_as_table: bool = True) -> str:
Expand Down
3 changes: 3 additions & 0 deletions tests/dialects/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,9 @@ def test_minus(self):
)

def test_values(self):
select = exp.select("*").from_("values (map(['a'], [1]))")
self.assertEqual(select.sql("snowflake"), "SELECT * FROM (SELECT OBJECT_CONSTRUCT('a', 1))")

self.validate_all(
'SELECT "c0", "c1" FROM (VALUES (1, 2), (3, 4)) AS "t0"("c0", "c1")',
read={
Expand Down

0 comments on commit ea197ea

Please sign in to comment.