summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/duckdb.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-03 06:02:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-03 06:02:50 +0000
commit766db5014d053a8aecf75d550c2a1b59022bcabf (patch)
tree7960e11339be3a1a4892d61f593903fe58fb9d55 /sqlglot/dialects/duckdb.py
parentReleasing debian version 10.5.10-1. (diff)
downloadsqlglot-766db5014d053a8aecf75d550c2a1b59022bcabf.tar.xz
sqlglot-766db5014d053a8aecf75d550c2a1b59022bcabf.zip
Merging upstream version 10.6.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/duckdb.py')
-rw-r--r--sqlglot/dialects/duckdb.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/sqlglot/dialects/duckdb.py b/sqlglot/dialects/duckdb.py
index 81941f7..4646eb4 100644
--- a/sqlglot/dialects/duckdb.py
+++ b/sqlglot/dialects/duckdb.py
@@ -66,12 +66,11 @@ def _sort_array_reverse(args):
return exp.SortArray(this=seq_get(args, 0), asc=exp.false())
-def _struct_pack_sql(self, expression):
+def _struct_sql(self, expression):
args = [
- self.binary(e, ":=") if isinstance(e, exp.EQ) else self.sql(e)
- for e in expression.expressions
+ f"'{e.name or e.this.name}': {self.sql(e, 'expression')}" for e in expression.expressions
]
- return f"STRUCT_PACK({', '.join(args)})"
+ return f"{{{', '.join(args)}}}"
def _datatype_sql(self, expression):
@@ -153,7 +152,7 @@ class DuckDB(Dialect):
exp.StrToDate: lambda self, e: f"CAST({_str_to_time_sql(self, e)} AS DATE)",
exp.StrToTime: _str_to_time_sql,
exp.StrToUnix: lambda self, e: f"EPOCH(STRPTIME({self.sql(e, 'this')}, {self.format_time(e)}))",
- exp.Struct: _struct_pack_sql,
+ exp.Struct: _struct_sql,
exp.TableSample: no_tablesample_sql,
exp.TimeStrToDate: lambda self, e: f"CAST({self.sql(e, 'this')} AS DATE)",
exp.TimeStrToTime: timestrtotime_sql,