Skip to content

Commit

Permalink
feat(snowflake): Transpile exp.StrToDate (#4348)
Browse files Browse the repository at this point in the history
  • Loading branch information
VaggelisD authored Nov 5, 2024
1 parent 1689dc7 commit 4584935
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/dialects/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ class Generator(generator.Generator):
exp.StrPosition: lambda self, e: self.func(
"POSITION", e.args.get("substr"), e.this, e.args.get("position")
),
exp.StrToDate: lambda self, e: self.func("DATE", e.this, self.format_time(e)),
exp.Stuff: rename_func("INSERT"),
exp.TimeAdd: date_delta_sql("TIMEADD"),
exp.Timestamp: no_timestamp_sql,
Expand Down
8 changes: 8 additions & 0 deletions tests/dialects/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,14 @@ def test_bigquery(self):
"duckdb": "SELECT CAST(STRPTIME('Thursday Dec 25 2008', '%A %b %-d %Y') AS DATE)",
},
)
self.validate_all(
"SELECT PARSE_DATE('%Y%m%d', '20081225')",
write={
"bigquery": "SELECT PARSE_DATE('%Y%m%d', '20081225')",
"duckdb": "SELECT CAST(STRPTIME('20081225', '%Y%m%d') AS DATE)",
"snowflake": "SELECT DATE('20081225', 'yyyymmDD')",
},
)
self.validate_all(
"SELECT ARRAY_TO_STRING(['cake', 'pie', NULL], '--') AS text",
write={
Expand Down

0 comments on commit 4584935

Please sign in to comment.