summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:43 +0000
commit341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87 (patch)
tree61fb7eca2238fb5d41d3906f4af41de03abd25ea /tests/test_parser.py
parentAdding upstream version 17.12.0. (diff)
downloadsqlglot-341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87.tar.xz
sqlglot-341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87.zip
Adding upstream version 18.2.0.upstream/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")