summaryrefslogtreecommitdiffstats
path: root/tests/test_executor.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-17 10:32:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-17 10:32:12 +0000
commit244a05de60c9417daab9528b51788c3d2a00dc5f (patch)
tree89a9c82aa41d397e1b81c320ad7a287b6c80f313 /tests/test_executor.py
parentAdding upstream version 10.4.2. (diff)
downloadsqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.tar.xz
sqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.zip
Adding upstream version 10.5.2.upstream/10.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.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_executor.py b/tests/test_executor.py
index b705551..f45a5d4 100644
--- a/tests/test_executor.py
+++ b/tests/test_executor.py
@@ -401,6 +401,36 @@ class TestExecutor(unittest.TestCase):
],
)
+ def test_correlated_count(self):
+ tables = {
+ "parts": [{"pnum": 0, "qoh": 1}],
+ "supplies": [],
+ }
+
+ schema = {
+ "parts": {"pnum": "int", "qoh": "int"},
+ "supplies": {"pnum": "int", "shipdate": "int"},
+ }
+
+ self.assertEqual(
+ execute(
+ """
+ select *
+ from parts
+ where parts.qoh >= (
+ select count(supplies.shipdate) + 1
+ from supplies
+ where supplies.pnum = parts.pnum and supplies.shipdate < 10
+ )
+ """,
+ tables=tables,
+ schema=schema,
+ ).rows,
+ [
+ (0, 1),
+ ],
+ )
+
def test_table_depth_mismatch(self):
tables = {"table": []}
schema = {"db": {"table": {"col": "VARCHAR"}}}