summaryrefslogtreecommitdiffstats
path: root/tests/test_schema.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:48:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:48:11 +0000
commit379c6d1f52e1d311867c4f789dc389da1d9af898 (patch)
treec9ca62eb7b8b7e861cc67248850db220ad0881c9 /tests/test_schema.py
parentReleasing debian version 17.7.0-1. (diff)
downloadsqlglot-379c6d1f52e1d311867c4f789dc389da1d9af898.tar.xz
sqlglot-379c6d1f52e1d311867c4f789dc389da1d9af898.zip
Merging upstream version 17.9.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_schema.py')
-rw-r--r--tests/test_schema.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_schema.py b/tests/test_schema.py
index b89754f..626fa11 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -238,3 +238,37 @@ class TestSchema(unittest.TestCase):
schema = MappingSchema(schema={"Foo": {"`BaR`": "int"}}, dialect="bigquery")
self.assertEqual(schema.column_names("Foo"), ["bar"])
self.assertEqual(schema.column_names("foo"), [])
+
+ # Check that the schema's normalization setting can be overridden
+ schema = MappingSchema(schema={"X": {"y": "int"}}, normalize=False, dialect="snowflake")
+ self.assertEqual(schema.column_names("x", normalize=True), ["y"])
+
+ def test_same_number_of_qualifiers(self):
+ schema = MappingSchema({"x": {"y": {"c1": "int"}}})
+
+ with self.assertRaises(SchemaError) as ctx:
+ schema.add_table("z", {"c2": "int"})
+
+ self.assertEqual(
+ str(ctx.exception),
+ "Table z must match the schema's nesting level: 2.",
+ )
+
+ schema = MappingSchema()
+ schema.add_table("x.y", {"c1": "int"})
+
+ with self.assertRaises(SchemaError) as ctx:
+ schema.add_table("z", {"c2": "int"})
+
+ self.assertEqual(
+ str(ctx.exception),
+ "Table z must match the schema's nesting level: 2.",
+ )
+
+ with self.assertRaises(SchemaError) as ctx:
+ MappingSchema({"x": {"y": {"c1": "int"}}, "z": {"c2": "int"}})
+
+ self.assertEqual(
+ str(ctx.exception),
+ "Table z must match the schema's nesting level: 2.",
+ )