diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-12-09 04:35:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-12-09 04:35:58 +0000 |
commit | 0b7fdf5c8079fa3f09be1ba5823fb6274746303d (patch) | |
tree | edc3d8cdec1a8eabd9361052fbfb7c14d719e6ce /tests/dialects/test_mysql.py | |
parent | Releasing debian version 25.32.1-1. (diff) | |
download | sqlglot-0b7fdf5c8079fa3f09be1ba5823fb6274746303d.tar.xz sqlglot-0b7fdf5c8079fa3f09be1ba5823fb6274746303d.zip |
Merging upstream version 25.34.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/dialects/test_mysql.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py index 9e5b74e..18cd374 100644 --- a/tests/dialects/test_mysql.py +++ b/tests/dialects/test_mysql.py @@ -1273,22 +1273,27 @@ COMMENT='客户账户表'""" ) def test_timestamp_trunc(self): - for dialect in ("postgres", "snowflake", "duckdb", "spark", "databricks"): + hive_dialects = ("spark", "databricks") + for dialect in ("postgres", "snowflake", "duckdb", *hive_dialects): for unit in ( - "MILLISECOND", "SECOND", "DAY", "MONTH", "YEAR", ): with self.subTest(f"MySQL -> {dialect} Timestamp Trunc with unit {unit}: "): + cast = ( + "TIMESTAMP('2001-02-16 20:38:40')" + if dialect in hive_dialects + else "CAST('2001-02-16 20:38:40' AS DATETIME)" + ) self.validate_all( - f"DATE_ADD('0000-01-01 00:00:00', INTERVAL (TIMESTAMPDIFF({unit}, '0000-01-01 00:00:00', CAST('2001-02-16 20:38:40' AS DATETIME))) {unit})", + f"DATE_ADD('0000-01-01 00:00:00', INTERVAL (TIMESTAMPDIFF({unit}, '0000-01-01 00:00:00', {cast})) {unit})", read={ dialect: f"DATE_TRUNC({unit}, TIMESTAMP '2001-02-16 20:38:40')", }, write={ - "mysql": f"DATE_ADD('0000-01-01 00:00:00', INTERVAL (TIMESTAMPDIFF({unit}, '0000-01-01 00:00:00', CAST('2001-02-16 20:38:40' AS DATETIME))) {unit})", + "mysql": f"DATE_ADD('0000-01-01 00:00:00', INTERVAL (TIMESTAMPDIFF({unit}, '0000-01-01 00:00:00', {cast})) {unit})", }, ) |