summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 08:03:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 08:03:58 +0000
commit9f19773cebdc9476f2a3266d3c01c967c38fcd1e (patch)
treea60f607ba2bb64fb45da86c297ff29ffc9b92f58 /tests/test_optimizer.py
parentReleasing debian version 16.7.3-1. (diff)
downloadsqlglot-9f19773cebdc9476f2a3266d3c01c967c38fcd1e.tar.xz
sqlglot-9f19773cebdc9476f2a3266d3c01c967c38fcd1e.zip
Merging upstream version 16.7.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r--tests/test_optimizer.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py
index b7425af..40eef9f 100644
--- a/tests/test_optimizer.py
+++ b/tests/test_optimizer.py
@@ -1,6 +1,7 @@
import unittest
from concurrent.futures import ProcessPoolExecutor, as_completed
from functools import partial
+from unittest.mock import patch
import duckdb
from pandas.testing import assert_frame_equal
@@ -14,6 +15,7 @@ from sqlglot.schema import MappingSchema
from tests.helpers import (
TPCDS_SCHEMA,
TPCH_SCHEMA,
+ assert_logger_contains,
load_sql_fixture_pairs,
load_sql_fixtures,
string_to_bool,
@@ -411,6 +413,15 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
{"s.b"},
)
+ @patch("sqlglot.optimizer.scope.logger")
+ def test_scope_warning(self, logger):
+ self.assertEqual(len(traverse_scope(parse_one("WITH q AS (@y) SELECT * FROM q"))), 1)
+ assert_logger_contains(
+ "Cannot traverse scope %s with type '%s'",
+ logger,
+ level="warning",
+ )
+
def test_literal_type_annotation(self):
tests = {
"SELECT 5": exp.DataType.Type.INT,