summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_dialect.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dialects/test_dialect.py')
-rw-r--r--tests/dialects/test_dialect.py41
1 files changed, 28 insertions, 13 deletions
diff --git a/tests/dialects/test_dialect.py b/tests/dialects/test_dialect.py
index 3558d62..bcbbfd6 100644
--- a/tests/dialects/test_dialect.py
+++ b/tests/dialects/test_dialect.py
@@ -435,6 +435,7 @@ class TestDialect(Validator):
write={
"duckdb": "EPOCH(CAST('2020-01-01' AS TIMESTAMP))",
"hive": "UNIX_TIMESTAMP('2020-01-01')",
+ "mysql": "UNIX_TIMESTAMP('2020-01-01')",
"presto": "TO_UNIXTIME(DATE_PARSE('2020-01-01', '%Y-%m-%d %T'))",
},
)
@@ -561,25 +562,25 @@ class TestDialect(Validator):
},
)
self.validate_all(
- "DATE_ADD(x, 1, 'day')",
+ "DATE_ADD(x, 1, 'DAY')",
read={
"mysql": "DATE_ADD(x, INTERVAL 1 DAY)",
- "snowflake": "DATEADD('day', 1, x)",
+ "snowflake": "DATEADD('DAY', 1, x)",
"starrocks": "DATE_ADD(x, INTERVAL 1 DAY)",
},
write={
"bigquery": "DATE_ADD(x, INTERVAL 1 DAY)",
"drill": "DATE_ADD(x, INTERVAL 1 DAY)",
- "duckdb": "x + INTERVAL 1 day",
+ "duckdb": "x + INTERVAL 1 DAY",
"hive": "DATE_ADD(x, 1)",
"mysql": "DATE_ADD(x, INTERVAL 1 DAY)",
- "postgres": "x + INTERVAL '1' day",
- "presto": "DATE_ADD('day', 1, x)",
- "snowflake": "DATEADD(day, 1, x)",
+ "postgres": "x + INTERVAL '1' DAY",
+ "presto": "DATE_ADD('DAY', 1, x)",
+ "snowflake": "DATEADD(DAY, 1, x)",
"spark": "DATE_ADD(x, 1)",
- "sqlite": "DATE(x, '1 day')",
+ "sqlite": "DATE(x, '1 DAY')",
"starrocks": "DATE_ADD(x, INTERVAL 1 DAY)",
- "tsql": "DATEADD(day, 1, x)",
+ "tsql": "DATEADD(DAY, 1, x)",
},
)
self.validate_all(
@@ -632,13 +633,13 @@ class TestDialect(Validator):
},
)
self.validate_all(
+ "TIMESTAMP_TRUNC(TRY_CAST(x AS DATE), day)",
+ read={"postgres": "DATE_TRUNC('day', x::DATE)"},
+ )
+ self.validate_all(
"TIMESTAMP_TRUNC(CAST(x AS DATE), day)",
- read={
- "postgres": "DATE_TRUNC('day', x::DATE)",
- "starrocks": "DATE_TRUNC('day', x::DATE)",
- },
+ read={"starrocks": "DATE_TRUNC('day', x::DATE)"},
)
-
self.validate_all(
"DATE_TRUNC('week', x)",
write={
@@ -752,6 +753,20 @@ class TestDialect(Validator):
},
)
self.validate_all(
+ "TS_OR_DS_ADD(x, 1, 'DAY')",
+ write={
+ "presto": "DATE_ADD('DAY', 1, DATE_PARSE(SUBSTR(CAST(x AS VARCHAR), 1, 10), '%Y-%m-%d'))",
+ "hive": "DATE_ADD(x, 1)",
+ },
+ )
+ self.validate_all(
+ "TS_OR_DS_ADD(CURRENT_DATE, 1, 'DAY')",
+ write={
+ "presto": "DATE_ADD('DAY', 1, CURRENT_DATE)",
+ "hive": "DATE_ADD(CURRENT_DATE, 1)",
+ },
+ )
+ self.validate_all(
"DATE_ADD(CAST('2020-01-01' AS DATE), 1)",
write={
"drill": "DATE_ADD(CAST('2020-01-01' AS DATE), INTERVAL 1 DAY)",