summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index bff4f98..91fd4c6 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -4,6 +4,7 @@ from unittest.mock import patch
from sqlglot import Parser, exp, parse, parse_one
from sqlglot.errors import ErrorLevel, ParseError
+from sqlglot.parser import logger as parser_logger
from tests.helpers import assert_logger_contains
@@ -151,11 +152,14 @@ class TestParser(unittest.TestCase):
)
def test_command(self):
- expressions = parse("SET x = 1; ADD JAR s3://a; SELECT 1", read="hive")
- self.assertEqual(len(expressions), 3)
- self.assertEqual(expressions[0].sql(), "SET x = 1")
- self.assertEqual(expressions[1].sql(), "ADD JAR s3://a")
- self.assertEqual(expressions[2].sql(), "SELECT 1")
+ with self.assertLogs(parser_logger) as cm:
+ expressions = parse("SET x = 1; ADD JAR s3://a; SELECT 1", read="hive")
+ self.assertEqual(len(expressions), 3)
+ self.assertEqual(expressions[0].sql(), "SET x = 1")
+ self.assertEqual(expressions[1].sql(), "ADD JAR s3://a")
+ self.assertEqual(expressions[2].sql(), "SELECT 1")
+
+ assert "'ADD JAR s3://a'" in cm.output[0]
def test_lambda_struct(self):
expression = parse_one("FILTER(a.b, x -> x.id = id)")
@@ -272,6 +276,8 @@ class TestParser(unittest.TestCase):
with self.assertRaises(ParseError):
parse_one("SELECT A[:")
+ self.assertEqual(parse_one("as as", error_level=ErrorLevel.IGNORE).sql(), "AS as")
+
def test_space(self):
self.assertEqual(
parse_one("SELECT ROW() OVER(PARTITION BY x) FROM x GROUP BY y").sql(),
@@ -504,7 +510,9 @@ class TestParser(unittest.TestCase):
self.assertEqual(set_to.sql(), "SET x = 1")
self.assertIsInstance(set_to, exp.Set)
- set_as_command = parse_one("SET DEFAULT ROLE ALL TO USER")
+ with self.assertLogs(parser_logger) as cm:
+ set_as_command = parse_one("SET DEFAULT ROLE ALL TO USER")
+ assert "'SET DEFAULT ROLE ALL TO USER'" in cm.output[0]
self.assertEqual(set_as_command.sql(), "SET DEFAULT ROLE ALL TO USER")