diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-07 12:35:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-07 12:35:01 +0000 |
commit | 58c11f70074708344e433080e47621091a6dcd84 (patch) | |
tree | 2589166e0e58be4947e07a956d26efa497bccaf2 /tests/test_executor.py | |
parent | Adding upstream version 11.4.5. (diff) | |
download | sqlglot-58c11f70074708344e433080e47621091a6dcd84.tar.xz sqlglot-58c11f70074708344e433080e47621091a6dcd84.zip |
Adding upstream version 11.5.2.upstream/11.5.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_executor.py')
-rw-r--r-- | tests/test_executor.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_executor.py b/tests/test_executor.py index c455f3a..6bf7d6a 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -1,3 +1,4 @@ +import datetime import unittest from datetime import date @@ -513,6 +514,8 @@ class TestExecutor(unittest.TestCase): self.assertEqual(result.rows, [(3,)]) def test_scalar_functions(self): + now = datetime.datetime.now() + for sql, expected in [ ("CONCAT('a', 'b')", "ab"), ("CONCAT('a', NULL)", None), @@ -569,6 +572,26 @@ class TestExecutor(unittest.TestCase): ("NULL IS NOT NULL", False), ("NULL = NULL", None), ("NULL <> NULL", None), + ("YEAR(CURRENT_TIMESTAMP)", now.year), + ("MONTH(CURRENT_TIME)", now.month), + ("DAY(CURRENT_DATETIME())", now.day), + ("YEAR(CURRENT_DATE())", now.year), + ("MONTH(CURRENT_DATE())", now.month), + ("DAY(CURRENT_DATE())", now.day), + ("YEAR(CURRENT_TIMESTAMP) + 1", now.year + 1), + ( + "YEAR(CURRENT_TIMESTAMP) IN (YEAR(CURRENT_TIMESTAMP) + 1, YEAR(CURRENT_TIMESTAMP) * 10)", + False, + ), + ("YEAR(CURRENT_TIMESTAMP) = (YEAR(CURRENT_TIMESTAMP))", True), + ("YEAR(CURRENT_TIMESTAMP) <> (YEAR(CURRENT_TIMESTAMP))", False), + ("YEAR(CURRENT_DATE()) + 1", now.year + 1), + ( + "YEAR(CURRENT_DATE()) IN (YEAR(CURRENT_DATE()) + 1, YEAR(CURRENT_DATE()) * 10)", + False, + ), + ("YEAR(CURRENT_DATE()) = (YEAR(CURRENT_DATE()))", True), + ("YEAR(CURRENT_DATE()) <> (YEAR(CURRENT_DATE()))", False), ]: with self.subTest(sql): result = execute(f"SELECT {sql}") |