summaryrefslogtreecommitdiffstats
path: root/tests/test_schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_schema.py')
-rw-r--r--tests/test_schema.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/test_schema.py b/tests/test_schema.py
index 92cf04a..b03e7e7 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -210,14 +210,22 @@ class TestSchema(unittest.TestCase):
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"])
- # Check that add_table normalizes both the table and the column names to be added/updated
+ # Check that add_table normalizes both the table and the column names to be added / updated
schema = MappingSchema()
schema.add_table("Foo", {"SomeColumn": "INT", '"SomeColumn"': "DOUBLE"})
+ self.assertEqual(schema.column_names(exp.Table(this="fOO")), ["somecolumn", "SomeColumn"])
- table_foo = exp.Table(this="fOO")
+ # Check that names are normalized to uppercase for Snowflake
+ schema = MappingSchema(schema={"x": {"foo": "int", '"bLa"': "int"}}, dialect="snowflake")
+ self.assertEqual(schema.column_names(exp.Table(this="x")), ["FOO", "bLa"])
- self.assertEqual(schema.column_names(table_foo), ["somecolumn", "SomeColumn"])
+ # Check that switching off the normalization logic works as expected
+ schema = MappingSchema(schema={"x": {"foo": "int"}}, normalize=False, dialect="snowflake")
+ self.assertEqual(schema.column_names(exp.Table(this="x")), ["foo"])
+
+ # Check that the correct dialect is used when calling schema methods
+ schema = MappingSchema(schema={"[Fo]": {"x": "int"}}, dialect="tsql")
+ self.assertEqual(schema.column_names("[Fo]"), schema.column_names("`Fo`", dialect="spark"))