Skip to content

Commit

Permalink
fix: allow snowflake object_construct with string keys to transpile t…
Browse files Browse the repository at this point in the history
…o sqlglot dialect
  • Loading branch information
tobymao committed Mar 25, 2024
1 parent ec4648f commit e4dd052
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sqlglot/generator.py
Expand Up @@ -3586,7 +3586,9 @@ def struct_sql(self, expression: exp.Struct) -> str:
expression.set(
"expressions",
[
exp.alias_(e.expression, e.this) if isinstance(e, exp.PropertyEQ) else e
exp.alias_(e.expression, e.name if e.this.is_string else e.this)
if isinstance(e, exp.PropertyEQ)
else e
for e in expression.expressions
],
)
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_snowflake.py
Expand Up @@ -396,6 +396,7 @@ def test_snowflake(self):
write={
"duckdb": "{'a': b, 'c': d}",
"snowflake": "OBJECT_CONSTRUCT('a', b, 'c', d)",
"": "STRUCT(b AS a, d AS c)",
},
)
self.validate_identity("OBJECT_CONSTRUCT(a, b, c, d)")
Expand Down

0 comments on commit e4dd052

Please sign in to comment.