diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-01-23 05:06:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-01-23 05:06:10 +0000 |
commit | 258c7df9cab21a4978c100568907ac1cb7fd6ee0 (patch) | |
tree | a98c4c9fc7433833be72543de5d99d15b9927442 /tests/test_parser.py | |
parent | Adding upstream version 20.4.0. (diff) | |
download | sqlglot-258c7df9cab21a4978c100568907ac1cb7fd6ee0.tar.xz sqlglot-258c7df9cab21a4978c100568907ac1cb7fd6ee0.zip |
Adding upstream version 20.9.0.upstream/20.9.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r-- | tests/test_parser.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py index 6611b87..bff4f98 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -86,6 +86,15 @@ class TestParser(unittest.TestCase): self.assertIsNotNone(parse_one("date").find(exp.Column)) + def test_structs(self): + cast = parse_one("cast(x as struct<int>)") + self.assertIsInstance(cast.to.expressions[0], exp.DataType) + self.assertEqual(cast.sql(), "CAST(x AS STRUCT<INT>)") + + cast = parse_one("cast(x as struct<varchar(10)>)") + self.assertIsInstance(cast.to.expressions[0], exp.DataType) + self.assertEqual(cast.sql(), "CAST(x AS STRUCT<VARCHAR(10)>)") + def test_float(self): self.assertEqual(parse_one(".2"), parse_one("0.2")) @@ -772,7 +781,7 @@ class TestParser(unittest.TestCase): ) self.assertEqual(ast.find(exp.Interval).this.sql(), "'71'") - self.assertEqual(ast.find(exp.Interval).unit.assert_is(exp.Var).sql(), "days") + self.assertEqual(ast.find(exp.Interval).unit.assert_is(exp.Var).sql(), "DAYS") def test_parse_concat_ws(self): ast = parse_one("CONCAT_WS(' ', 'John', 'Doe')") |