From 376de8b6892deca7dc5d83035c047f1e13eb67ea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 31 Jan 2024 06:44:41 +0100 Subject: Merging upstream version 20.11.0. Signed-off-by: Daniel Baumann --- tests/test_parser.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tests/test_parser.py') 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") -- cgit v1.2.3