summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_teradata.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:02:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:02:12 +0000
commit07115fb6b7dc48595d30c3d1568fbeff0388d096 (patch)
treef8017ffa5da7c1a44443bbf5fc6c3937b243ac5e /tests/dialects/test_teradata.py
parentAdding upstream version 23.7.0. (diff)
downloadsqlglot-07115fb6b7dc48595d30c3d1568fbeff0388d096.tar.xz
sqlglot-07115fb6b7dc48595d30c3d1568fbeff0388d096.zip
Adding upstream version 23.10.0.upstream/23.10.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_teradata.py')
-rw-r--r--tests/dialects/test_teradata.py89
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/dialects/test_teradata.py b/tests/dialects/test_teradata.py
index a85ca8c..010b683 100644
--- a/tests/dialects/test_teradata.py
+++ b/tests/dialects/test_teradata.py
@@ -210,3 +210,92 @@ class TestTeradata(Validator):
"teradata": "TRYCAST('-2.5' AS DECIMAL(5, 2))",
},
)
+
+ def test_time(self):
+ self.validate_all(
+ "CURRENT_TIMESTAMP",
+ read={
+ "teradata": "CURRENT_TIMESTAMP",
+ "snowflake": "CURRENT_TIMESTAMP()",
+ },
+ )
+
+ self.validate_all(
+ "SELECT '2023-01-01' + INTERVAL '5' YEAR",
+ read={
+ "teradata": "SELECT '2023-01-01' + INTERVAL '5' YEAR",
+ "snowflake": "SELECT DATEADD(YEAR, 5, '2023-01-01')",
+ },
+ )
+ self.validate_all(
+ "SELECT '2023-01-01' - INTERVAL '5' YEAR",
+ read={
+ "teradata": "SELECT '2023-01-01' - INTERVAL '5' YEAR",
+ "snowflake": "SELECT DATEADD(YEAR, -5, '2023-01-01')",
+ },
+ )
+ self.validate_all(
+ "SELECT '2023-01-01' - INTERVAL '5' YEAR",
+ read={
+ "teradata": "SELECT '2023-01-01' - INTERVAL '5' YEAR",
+ "sqlite": "SELECT DATE_SUB('2023-01-01', 5, YEAR)",
+ },
+ )
+ self.validate_all(
+ "SELECT '2023-01-01' + INTERVAL '5' YEAR",
+ read={
+ "teradata": "SELECT '2023-01-01' + INTERVAL '5' YEAR",
+ "sqlite": "SELECT DATE_SUB('2023-01-01', -5, YEAR)",
+ },
+ )
+ self.validate_all(
+ "SELECT (90 * INTERVAL '1' DAY)",
+ read={
+ "teradata": "SELECT (90 * INTERVAL '1' DAY)",
+ "snowflake": "SELECT INTERVAL '1' QUARTER",
+ },
+ )
+ self.validate_all(
+ "SELECT (7 * INTERVAL '1' DAY)",
+ read={
+ "teradata": "SELECT (7 * INTERVAL '1' DAY)",
+ "snowflake": "SELECT INTERVAL '1' WEEK",
+ },
+ )
+ self.validate_all(
+ "SELECT '2023-01-01' + (90 * INTERVAL '5' DAY)",
+ read={
+ "teradata": "SELECT '2023-01-01' + (90 * INTERVAL '5' DAY)",
+ "snowflake": "SELECT DATEADD(QUARTER, 5, '2023-01-01')",
+ },
+ )
+ self.validate_all(
+ "SELECT '2023-01-01' + (7 * INTERVAL '5' DAY)",
+ read={
+ "teradata": "SELECT '2023-01-01' + (7 * INTERVAL '5' DAY)",
+ "snowflake": "SELECT DATEADD(WEEK, 5, '2023-01-01')",
+ },
+ )
+ self.validate_all(
+ "CAST(TO_CHAR(x, 'Q') AS INT)",
+ read={
+ "teradata": "CAST(TO_CHAR(x, 'Q') AS INT)",
+ "snowflake": "DATE_PART(QUARTER, x)",
+ "bigquery": "EXTRACT(QUARTER FROM x)",
+ },
+ )
+ self.validate_all(
+ "EXTRACT(MONTH FROM x)",
+ read={
+ "teradata": "EXTRACT(MONTH FROM x)",
+ "snowflake": "DATE_PART(MONTH, x)",
+ "bigquery": "EXTRACT(MONTH FROM x)",
+ },
+ )
+ self.validate_all(
+ "CAST(TO_CHAR(x, 'Q') AS INT)",
+ read={
+ "snowflake": "quarter(x)",
+ "teradata": "CAST(TO_CHAR(x, 'Q') AS INT)",
+ },
+ )