diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 08:11:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 08:11:50 +0000 |
commit | 8978da3b39d7ca3cf83ee30fcc63ffe0e5453fb2 (patch) | |
tree | 2e29f131dff77b31e84c957266de8f18655b6f88 /tests/test_executor.py | |
parent | Adding upstream version 22.2.0. (diff) | |
download | sqlglot-8978da3b39d7ca3cf83ee30fcc63ffe0e5453fb2.tar.xz sqlglot-8978da3b39d7ca3cf83ee30fcc63ffe0e5453fb2.zip |
Adding upstream version 23.7.0.upstream/23.7.0
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, 21 insertions, 2 deletions
diff --git a/tests/test_executor.py b/tests/test_executor.py index 981c1d4..1eaca14 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -1,7 +1,7 @@ import os import datetime import unittest -from datetime import date +from datetime import date, time from multiprocessing import Pool import duckdb @@ -640,6 +640,7 @@ class TestExecutor(unittest.TestCase): ("CAST(1 AS TEXT)", "1"), ("CAST('1' AS LONG)", 1), ("CAST('1.1' AS FLOAT)", 1.1), + ("CAST('12:05:01' AS TIME)", time(12, 5, 1)), ("COALESCE(NULL)", None), ("COALESCE(NULL, NULL)", None), ("COALESCE(NULL, 'b')", "b"), @@ -702,6 +703,18 @@ class TestExecutor(unittest.TestCase): ("ARRAY_JOIN(['hello', null ,'world'], ' ', ',')", "hello , world"), ("ARRAY_JOIN(['', null ,'world'], ' ', ',')", " , world"), ("STRUCT('foo', 'bar', null, null)", {"foo": "bar"}), + ("ROUND(1.5)", 2), + ("ROUND(1.2)", 1), + ("ROUND(1.2345, 2)", 1.23), + ("ROUND(NULL)", None), + ("UNIXTOTIME(1659981729)", datetime.datetime(2022, 8, 8, 18, 2, 9)), + ("TIMESTRTOTIME('2013-04-05 01:02:03')", datetime.datetime(2013, 4, 5, 1, 2, 3)), + ("UNIXTOTIME(40 * 365 * 86400)", datetime.datetime(2009, 12, 22, 00, 00, 00)), + ( + "STRTOTIME('08/03/2024 12:34:56', '%d/%m/%Y %H:%M:%S')", + datetime.datetime(2024, 3, 8, 12, 34, 56), + ), + ("STRTOTIME('27/01/2024', '%d/%m/%Y')", datetime.datetime(2024, 1, 27)), ]: with self.subTest(sql): result = execute(f"SELECT {sql}") @@ -807,7 +820,7 @@ class TestExecutor(unittest.TestCase): self.assertEqual(result.columns, columns) self.assertEqual(result.rows, expected) - def test_dict_values(self): + def test_nested_values(self): tables = {"foo": [{"raw": {"name": "Hello, World", "a": [{"b": 1}]}}]} result = execute("SELECT raw:name AS name FROM foo", read="snowflake", tables=tables) @@ -837,3 +850,9 @@ class TestExecutor(unittest.TestCase): self.assertEqual(result.columns, ("flavor",)) self.assertEqual(result.rows, [("cherry",), ("lime",), ("apple",)]) + + tables = {"t": [{"x": [1, 2, 3]}]} + + result = execute("SELECT x FROM t", dialect="duckdb", tables=tables) + self.assertEqual(result.columns, ("x",)) + self.assertEqual(result.rows, [([1, 2, 3],)]) |