From f73e9af131151f1e058446361c35b05c4c90bf10 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 7 Sep 2023 13:39:48 +0200 Subject: Merging upstream version 18.2.0. Signed-off-by: Daniel Baumann --- tests/test_parser.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/test_parser.py') diff --git a/tests/test_parser.py b/tests/test_parser.py index e7b0ca9..7135dd8 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -216,6 +216,9 @@ class TestParser(unittest.TestCase): with self.assertRaises(ParseError): parse_one("IF(a > 0)") + with self.assertRaises(ParseError): + parse_one("SELECT CASE FROM x") + with self.assertRaises(ParseError): parse_one("WITH cte AS (SELECT * FROM x)") @@ -435,7 +438,7 @@ class TestParser(unittest.TestCase): self.assertIsInstance(parse_one("TIMESTAMP('2022-01-01')"), exp.Func) self.assertIsInstance(parse_one("TIMESTAMP()"), exp.Func) self.assertIsInstance(parse_one("map.x"), exp.Column) - self.assertIsInstance(parse_one("CAST(x AS CHAR(5))").to.expressions[0], exp.DataTypeSize) + self.assertIsInstance(parse_one("CAST(x AS CHAR(5))").to.expressions[0], exp.DataTypeParam) self.assertEqual(parse_one("1::int64", dialect="bigquery"), parse_one("CAST(1 AS BIGINT)")) def test_set_expression(self): @@ -708,3 +711,11 @@ class TestParser(unittest.TestCase): parse_one("SELECT a, b ?? c ?? 'No Data' FROM z").sql(), "SELECT a, COALESCE(COALESCE(b, c), 'No Data') FROM z", ) + + def test_parse_intervals(self): + ast = parse_one( + "SELECT a FROM tbl WHERE a <= DATE '1998-12-01' - INTERVAL '71 days' GROUP BY b" + ) + + self.assertEqual(ast.find(exp.Interval).this.sql(), "'71'") + self.assertEqual(ast.find(exp.Interval).unit.assert_is(exp.Var).sql(), "days") -- cgit v1.2.3