diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-16 09:41:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-16 09:41:15 +0000 |
commit | 358a09296d7198a4cc142f1976de8f3eb3318e58 (patch) | |
tree | 762db96c44014dc4db5e9fc7f6709c138589155e /tests/test_expressions.py | |
parent | Adding upstream version 15.2.0. (diff) | |
download | sqlglot-358a09296d7198a4cc142f1976de8f3eb3318e58.tar.xz sqlglot-358a09296d7198a4cc142f1976de8f3eb3318e58.zip |
Adding upstream version 16.2.1.upstream/16.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r-- | tests/test_expressions.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py index 7735e78..c9b5279 100644 --- a/tests/test_expressions.py +++ b/tests/test_expressions.py @@ -534,6 +534,7 @@ class TestExpressions(unittest.TestCase): self.assertIsInstance(parse_one("HLL(a)"), exp.Hll) self.assertIsInstance(parse_one("ARRAY(time, foo)"), exp.Array) self.assertIsInstance(parse_one("STANDARD_HASH('hello', 'sha256')"), exp.StandardHash) + self.assertIsInstance(parse_one("DATE(foo)"), exp.Date) def test_column(self): column = parse_one("a.b.c.d") @@ -590,7 +591,7 @@ class TestExpressions(unittest.TestCase): unit = parse_one("timestamp_trunc(current_timestamp, week(thursday))") self.assertIsNotNone(unit.find(exp.CurrentTimestamp)) week = unit.find(exp.Week) - self.assertEqual(week.this, exp.Var(this="thursday")) + self.assertEqual(week.this, exp.var("thursday")) def test_identifier(self): self.assertTrue(exp.to_identifier('"x"').quoted) @@ -601,7 +602,7 @@ class TestExpressions(unittest.TestCase): def test_function_normalizer(self): self.assertEqual(parse_one("HELLO()").sql(normalize_functions="lower"), "hello()") self.assertEqual(parse_one("hello()").sql(normalize_functions="upper"), "HELLO()") - self.assertEqual(parse_one("heLLO()").sql(normalize_functions=None), "heLLO()") + self.assertEqual(parse_one("heLLO()").sql(normalize_functions=False), "heLLO()") self.assertEqual(parse_one("SUM(x)").sql(normalize_functions="lower"), "sum(x)") self.assertEqual(parse_one("sum(x)").sql(normalize_functions="upper"), "SUM(x)") @@ -786,7 +787,7 @@ FROM foo""", self.assertEqual(exp.DataType.build("DECIMAL").sql(), "DECIMAL") self.assertEqual(exp.DataType.build("BOOLEAN").sql(), "BOOLEAN") self.assertEqual(exp.DataType.build("JSON").sql(), "JSON") - self.assertEqual(exp.DataType.build("JSONB").sql(), "JSONB") + self.assertEqual(exp.DataType.build("JSONB", dialect="postgres").sql(), "JSONB") self.assertEqual(exp.DataType.build("INTERVAL").sql(), "INTERVAL") self.assertEqual(exp.DataType.build("TIME").sql(), "TIME") self.assertEqual(exp.DataType.build("TIMESTAMP").sql(), "TIMESTAMP") @@ -801,22 +802,17 @@ FROM foo""", self.assertEqual(exp.DataType.build("GEOMETRY").sql(), "GEOMETRY") self.assertEqual(exp.DataType.build("STRUCT").sql(), "STRUCT") self.assertEqual(exp.DataType.build("NULLABLE").sql(), "NULLABLE") - self.assertEqual(exp.DataType.build("HLLSKETCH").sql(), "HLLSKETCH") - self.assertEqual(exp.DataType.build("HSTORE").sql(), "HSTORE") - self.assertEqual(exp.DataType.build("SUPER").sql(), "SUPER") - self.assertEqual(exp.DataType.build("SERIAL").sql(), "SERIAL") - self.assertEqual(exp.DataType.build("SMALLSERIAL").sql(), "SMALLSERIAL") - self.assertEqual(exp.DataType.build("BIGSERIAL").sql(), "BIGSERIAL") - self.assertEqual(exp.DataType.build("XML").sql(), "XML") - self.assertEqual(exp.DataType.build("UNIQUEIDENTIFIER").sql(), "UNIQUEIDENTIFIER") - self.assertEqual(exp.DataType.build("MONEY").sql(), "MONEY") - self.assertEqual(exp.DataType.build("SMALLMONEY").sql(), "SMALLMONEY") - self.assertEqual(exp.DataType.build("ROWVERSION").sql(), "ROWVERSION") - self.assertEqual(exp.DataType.build("IMAGE").sql(), "IMAGE") - self.assertEqual(exp.DataType.build("VARIANT").sql(), "VARIANT") - self.assertEqual(exp.DataType.build("OBJECT").sql(), "OBJECT") + self.assertEqual(exp.DataType.build("HLLSKETCH", dialect="redshift").sql(), "HLLSKETCH") + self.assertEqual(exp.DataType.build("HSTORE", dialect="postgres").sql(), "HSTORE") self.assertEqual(exp.DataType.build("NULL").sql(), "NULL") + self.assertEqual(exp.DataType.build("NULL", dialect="bigquery").sql(), "NULL") self.assertEqual(exp.DataType.build("UNKNOWN").sql(), "UNKNOWN") + self.assertEqual(exp.DataType.build("UNKNOWN", dialect="bigquery").sql(), "UNKNOWN") + self.assertEqual(exp.DataType.build("UNKNOWN", dialect="snowflake").sql(), "UNKNOWN") + self.assertEqual(exp.DataType.build("TIMESTAMP", dialect="bigquery").sql(), "TIMESTAMPTZ") + self.assertEqual( + exp.DataType.build("struct<x int>", dialect="spark").sql(), "STRUCT<x INT>" + ) def test_rename_table(self): self.assertEqual( |