Merging upstream version 6.2.6.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
0f5b9ddee1
commit
66e2d714bf
49 changed files with 1741 additions and 566 deletions
|
@ -27,6 +27,8 @@ class TestExpressions(unittest.TestCase):
|
|||
parse_one("ROW() OVER (partition BY y)"),
|
||||
)
|
||||
self.assertEqual(parse_one("TO_DATE(x)", read="hive"), parse_one("ts_or_ds_to_date(x)"))
|
||||
self.assertEqual(exp.Table(pivots=[]), exp.Table())
|
||||
self.assertNotEqual(exp.Table(pivots=[None]), exp.Table())
|
||||
|
||||
def test_find(self):
|
||||
expression = parse_one("CREATE TABLE x STORED AS PARQUET AS SELECT * FROM y")
|
||||
|
@ -280,6 +282,19 @@ class TestExpressions(unittest.TestCase):
|
|||
expression.find(exp.Table).replace(parse_one("y"))
|
||||
self.assertEqual(expression.sql(), "SELECT c, b FROM y")
|
||||
|
||||
def test_pop(self):
|
||||
expression = parse_one("SELECT a, b FROM x")
|
||||
expression.find(exp.Column).pop()
|
||||
self.assertEqual(expression.sql(), "SELECT b FROM x")
|
||||
expression.find(exp.Column).pop()
|
||||
self.assertEqual(expression.sql(), "SELECT FROM x")
|
||||
expression.pop()
|
||||
self.assertEqual(expression.sql(), "SELECT FROM x")
|
||||
|
||||
expression = parse_one("WITH x AS (SELECT a FROM x) SELECT * FROM x")
|
||||
expression.find(exp.With).pop()
|
||||
self.assertEqual(expression.sql(), "SELECT * FROM x")
|
||||
|
||||
def test_walk(self):
|
||||
expression = parse_one("SELECT * FROM (SELECT * FROM x)")
|
||||
self.assertEqual(len(list(expression.walk())), 9)
|
||||
|
@ -316,6 +331,7 @@ class TestExpressions(unittest.TestCase):
|
|||
self.assertIsInstance(parse_one("MAX(a)"), exp.Max)
|
||||
self.assertIsInstance(parse_one("MIN(a)"), exp.Min)
|
||||
self.assertIsInstance(parse_one("MONTH(a)"), exp.Month)
|
||||
self.assertIsInstance(parse_one("POSITION(' ' IN a)"), exp.StrPosition)
|
||||
self.assertIsInstance(parse_one("POW(a, 2)"), exp.Pow)
|
||||
self.assertIsInstance(parse_one("POWER(a, 2)"), exp.Pow)
|
||||
self.assertIsInstance(parse_one("QUANTILE(a, 0.90)"), exp.Quantile)
|
||||
|
@ -420,7 +436,7 @@ class TestExpressions(unittest.TestCase):
|
|||
exp.Properties.from_dict(
|
||||
{
|
||||
"FORMAT": "parquet",
|
||||
"PARTITIONED_BY": [exp.to_identifier("a"), exp.to_identifier("b")],
|
||||
"PARTITIONED_BY": (exp.to_identifier("a"), exp.to_identifier("b")),
|
||||
"custom": 1,
|
||||
"TABLE_FORMAT": exp.to_identifier("test_format"),
|
||||
"ENGINE": None,
|
||||
|
@ -444,4 +460,17 @@ class TestExpressions(unittest.TestCase):
|
|||
),
|
||||
)
|
||||
|
||||
self.assertRaises(ValueError, exp.Properties.from_dict, {"FORMAT": {"key": "value"}})
|
||||
self.assertRaises(ValueError, exp.Properties.from_dict, {"FORMAT": object})
|
||||
|
||||
def test_convert(self):
|
||||
for value, expected in [
|
||||
(1, "1"),
|
||||
("1", "'1'"),
|
||||
(None, "NULL"),
|
||||
(True, "TRUE"),
|
||||
((1, "2", None), "(1, '2', NULL)"),
|
||||
([1, "2", None], "ARRAY(1, '2', NULL)"),
|
||||
({"x": None}, "MAP('x', NULL)"),
|
||||
]:
|
||||
with self.subTest(value):
|
||||
self.assertEqual(exp.convert(value).sql(), expected)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue