summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:50 +0000
commit4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53 (patch)
tree1084b1a2dd9f2782031b4aa79608db08968a5837 /tests/test_parser.py
parentReleasing debian version 17.9.1-1. (diff)
downloadsqlglot-4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53.tar.xz
sqlglot-4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53.zip
Merging upstream version 17.11.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 027a9ca..e7b0ca9 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -219,6 +219,9 @@ class TestParser(unittest.TestCase):
with self.assertRaises(ParseError):
parse_one("WITH cte AS (SELECT * FROM x)")
+ with self.assertRaises(ParseError):
+ parse_one("SELECT foo( FROM bar")
+
self.assertEqual(
parse_one(
"CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()",
@@ -694,3 +697,14 @@ class TestParser(unittest.TestCase):
def test_parse_floats(self):
self.assertTrue(parse_one("1. ").is_number)
+
+ def test_parse_terse_coalesce(self):
+ self.assertIsNotNone(parse_one("SELECT x ?? y FROM z").find(exp.Coalesce))
+ self.assertEqual(
+ parse_one("SELECT a, b ?? 'No Data' FROM z").sql(),
+ "SELECT a, COALESCE(b, 'No Data') FROM z",
+ )
+ self.assertEqual(
+ parse_one("SELECT a, b ?? c ?? 'No Data' FROM z").sql(),
+ "SELECT a, COALESCE(COALESCE(b, c), 'No Data') FROM z",
+ )