Skip to content

Commit

Permalink
Feat(postgres): struct_extract
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Sep 29, 2023
1 parent 341e817 commit 4665016
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sqlglot/dialects/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
rename_func,
simplify_literal,
str_position_sql,
struct_extract_sql,
timestamptrunc_sql,
timestrtotime_sql,
trim_sql,
Expand Down Expand Up @@ -427,6 +428,7 @@ class Generator(generator.Generator):
),
exp.StrPosition: str_position_sql,
exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
exp.StructExtract: struct_extract_sql,
exp.Substring: _substring_sql,
exp.TimestampTrunc: timestamptrunc_sql,
exp.TimeStrToTime: timestrtotime_sql,
Expand Down
2 changes: 2 additions & 0 deletions tests/dialects/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ def test_duckdb(self):
"duckdb": "STRUCT_EXTRACT(x, 'abc')",
"presto": "x.abc",
"hive": "x.abc",
"postgres": "x.abc",
"redshift": "x.abc",
"spark": "x.abc",
},
)
Expand Down

0 comments on commit 4665016

Please sign in to comment.