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.py13
1 files changed, 12 insertions, 1 deletions
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
@@ -217,6 +217,9 @@ class TestParser(unittest.TestCase):
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)")
with self.assertRaises(ParseError):
@@ -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")