diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-17 10:32:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-17 10:32:12 +0000 |
commit | 244a05de60c9417daab9528b51788c3d2a00dc5f (patch) | |
tree | 89a9c82aa41d397e1b81c320ad7a287b6c80f313 /tests/test_schema.py | |
parent | Adding upstream version 10.4.2. (diff) | |
download | sqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.tar.xz sqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.zip |
Adding upstream version 10.5.2.upstream/10.5.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_schema.py')
-rw-r--r-- | tests/test_schema.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_schema.py b/tests/test_schema.py index 6c1ca9c..3dd9103 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -184,3 +184,19 @@ class TestSchema(unittest.TestCase): schema = MappingSchema({"foo": {"bar": parse_one("INT", into=exp.DataType)}}) self.assertEqual(schema.get_column_type("foo", "bar").this, exp.DataType.Type.INT) + + def test_schema_normalization(self): + schema = MappingSchema( + schema={"x": {"`y`": {"Z": {"a": "INT", "`B`": "VARCHAR"}, "w": {"C": "INT"}}}}, + dialect="spark", + ) + + table_z = exp.Table(this="z", db="y", catalog="x") + table_w = exp.Table(this="w", db="y", catalog="x") + + self.assertEqual(schema.column_names(table_z), ["a", "B"]) + self.assertEqual(schema.column_names(table_w), ["c"]) + + # Clickhouse supports both `` and "" for identifier quotes; sqlglot uses "" when generating sql + schema = MappingSchema(schema={"x": {"`y`": "INT"}}, dialect="clickhouse") + self.assertEqual(schema.column_names(exp.Table(this="x")), ["y"]) |