Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sqlglot/dialects/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Postgres(Dialect):
"FMSS": "%-S", # Second
"HH12": "%I", # 09
"HH24": "%H", # 09
"iw": "%V", # ISO 8601 week of year
"IW": "%V", # ISO 8601 week of year
"iyyy": "%G", # ISO 8601 week-numbering year
"IYYY": "%G", # ISO 8601 week-numbering year
"mi": "%M", # zero padded minute
"MI": "%M", # zero padded minute
"mm": "%m", # 01
Expand Down
11 changes: 11 additions & 0 deletions tests/dialects/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,17 @@ def test_postgres(self):
"postgres": "SELECT TO_DATE('01/01/2000', 'MM/DD/YYYY')",
},
)
self.validate_all(
"SELECT TO_CHAR(x, 'IYYY-IW')",
read={
"duckdb": "SELECT STRFTIME(x, '%G-%V')",
"postgres": "SELECT TO_CHAR(x, 'iyyy-iw')",
},
write={
"duckdb": "SELECT STRFTIME(x, '%G-%V')",
"postgres": "SELECT TO_CHAR(x, 'IYYY-IW')",
},
)

self.validate_identity(
'SELECT js, js IS JSON AS "json?", js IS JSON VALUE AS "scalar?", js IS JSON SCALAR AS "scalar?", js IS JSON OBJECT AS "object?", js IS JSON ARRAY AS "array?" FROM t'
Expand Down
Loading