summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:48 +0000
commitf73e9af131151f1e058446361c35b05c4c90bf10 (patch)
treeed425b89f12d3f5e4709290bdc03d876f365bc97 /tests/test_parser.py
parentReleasing debian version 17.12.0-1. (diff)
downloadsqlglot-f73e9af131151f1e058446361c35b05c4c90bf10.tar.xz
sqlglot-f73e9af131151f1e058446361c35b05c4c90bf10.zip
Merging upstream version 18.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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")