summaryrefslogtreecommitdiffstats
path: root/tests/test_executor.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-06 07:28:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-06 07:28:09 +0000
commit52f4a5e2260f3e5b919b4e270339afd670bf0b8a (patch)
tree5ca419af0e2e409018492b82f5b9847f0112b5fb /tests/test_executor.py
parentAdding upstream version 16.7.7. (diff)
downloadsqlglot-52f4a5e2260f3e5b919b4e270339afd670bf0b8a.tar.xz
sqlglot-52f4a5e2260f3e5b919b4e270339afd670bf0b8a.zip
Adding upstream version 17.2.0.upstream/17.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_executor.py')
-rw-r--r--tests/test_executor.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/test_executor.py b/tests/test_executor.py
index 6dd530f..9dacbbf 100644
--- a/tests/test_executor.py
+++ b/tests/test_executor.py
@@ -58,8 +58,11 @@ class TestExecutor(unittest.TestCase):
source.rename(columns={column: target.columns[i]}, inplace=True)
def test_py_dialect(self):
- self.assertEqual(Python().generate(parse_one("'x '''")), r"'x \''")
- self.assertEqual(Python().generate(parse_one("MAP([1], [2])")), "MAP([1], [2])")
+ generate = Python().generate
+ self.assertEqual(generate(parse_one("'x '''")), r"'x \''")
+ self.assertEqual(generate(parse_one("MAP([1], [2])")), "MAP([1], [2])")
+ self.assertEqual(generate(parse_one("1 is null")), "1 == None")
+ self.assertEqual(generate(parse_one("x is null")), "scope[None][x] is None")
def test_optimized_tpch(self):
for i, (sql, optimized) in enumerate(self.sqls[:20], start=1):
@@ -620,6 +623,7 @@ class TestExecutor(unittest.TestCase):
("TIMESTRTOTIME('2022-01-01')", datetime.datetime(2022, 1, 1)),
("LEFT('12345', 3)", "123"),
("RIGHT('12345', 3)", "345"),
+ ("DATEDIFF('2022-01-03'::date, '2022-01-01'::TIMESTAMP::DATE)", 2),
]:
with self.subTest(sql):
result = execute(f"SELECT {sql}")
@@ -699,6 +703,21 @@ class TestExecutor(unittest.TestCase):
[(2, 25.0)],
("_col_0", "_col_1"),
),
+ (
+ "SELECT a FROM x GROUP BY a ORDER BY AVG(b)",
+ [(2,), (1,), (3,)],
+ ("a",),
+ ),
+ (
+ "SELECT a, SUM(b) FROM x GROUP BY a ORDER BY COUNT(*)",
+ [(3, 28), (1, 50), (2, 45)],
+ ("a", "_col_1"),
+ ),
+ (
+ "SELECT a, SUM(b) FROM x GROUP BY a ORDER BY COUNT(*) DESC",
+ [(1, 50), (2, 45), (3, 28)],
+ ("a", "_col_1"),
+ ),
):
with self.subTest(sql):
result = execute(sql, tables=tables)