-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix #22911 [1]: add support for more column datatypes #26979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c5624dc
be65c6a
aa2f245
bfe472f
e43a2dc
618ed17
2708b58
b28821a
0b0277b
4738125
a8ef598
eed2315
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,3 +68,69 @@ def test_nullable_unwraps_to_inner_type(self): | |||||||||||||
| def test_unknown_type_returns_null_type(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "SomeUnknownType") | ||||||||||||||
| assert result is sqltypes.NullType | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| class TestClickhouseGeoTypes: | ||||||||||||||
| """Verify that ClickHouse geo types are registered in ischema_names | ||||||||||||||
| and resolved correctly by _get_column_type.""" | ||||||||||||||
|
|
||||||||||||||
| def setup_method(self): | ||||||||||||||
| self.dialect = MockDialect() | ||||||||||||||
|
|
||||||||||||||
| # --- Registration checks --- | ||||||||||||||
|
|
||||||||||||||
| def test_geo_types_registered_in_ischema_names(self): | ||||||||||||||
| for geo_type in ( | ||||||||||||||
| "Point", | ||||||||||||||
| "Ring", | ||||||||||||||
| "Polygon", | ||||||||||||||
| "MultiPolygon", | ||||||||||||||
| "LineString", | ||||||||||||||
| "MultiLineString", | ||||||||||||||
| ): | ||||||||||||||
| assert ( | ||||||||||||||
| geo_type in ch_ischema_names | ||||||||||||||
| ), f"{geo_type} not found in ischema_names" | ||||||||||||||
|
|
||||||||||||||
| # --- Resolution via _get_column_type --- | ||||||||||||||
|
|
||||||||||||||
| def test_point_type_resolves(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "Point") | ||||||||||||||
| assert result == ch_ischema_names["Point"] | ||||||||||||||
|
|
||||||||||||||
| def test_ring_type_resolves(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "Ring") | ||||||||||||||
| assert result == ch_ischema_names["Ring"] | ||||||||||||||
|
|
||||||||||||||
| def test_polygon_type_resolves(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "Polygon") | ||||||||||||||
| assert result == ch_ischema_names["Polygon"] | ||||||||||||||
|
|
||||||||||||||
| def test_multipolygon_type_resolves(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "MultiPolygon") | ||||||||||||||
| assert result == ch_ischema_names["MultiPolygon"] | ||||||||||||||
|
|
||||||||||||||
| def test_linestring_type_resolves(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "LineString") | ||||||||||||||
| assert result == ch_ischema_names["LineString"] | ||||||||||||||
|
|
||||||||||||||
| def test_multilinestring_type_resolves(self): | ||||||||||||||
| result = self.dialect._get_column_type("col", "MultiLineString") | ||||||||||||||
| assert result == ch_ischema_names["MultiLineString"] | ||||||||||||||
|
SumanMaharana marked this conversation as resolved.
|
||||||||||||||
|
|
||||||||||||||
| def test_geo_types_are_distinct(self): | ||||||||||||||
| """Each geo type should resolve to a different object.""" | ||||||||||||||
| types = { | ||||||||||||||
| name: ch_ischema_names[name] | ||||||||||||||
| for name in ( | ||||||||||||||
| "Point", | ||||||||||||||
| "Ring", | ||||||||||||||
| "Polygon", | ||||||||||||||
| "MultiPolygon", | ||||||||||||||
| "LineString", | ||||||||||||||
| "MultiLineString", | ||||||||||||||
| ) | ||||||||||||||
| } | ||||||||||||||
| # All values should be distinct from NullType | ||||||||||||||
| for name, t in types.items(): | ||||||||||||||
| assert t is not sqltypes.NullType, f"{name} resolved to NullType" | ||||||||||||||
|
||||||||||||||
| assert t is not sqltypes.NullType, f"{name} resolved to NullType" | |
| assert t is not sqltypes.NullType, f"{name} resolved to NullType" | |
| # And all geo types should map to distinct objects | |
| assert len(set(types.values())) == len( | |
| types | |
| ), "Geo types do not resolve to distinct objects" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ | |
| MSSQL_GET_DATABASE, | ||
| MSSQL_TEST_GET_QUERIES, | ||
| ) | ||
| from metadata.utils.sqa_utils import update_mssql_ischema_names | ||
|
|
||
| mock_mssql_config = { | ||
| "source": { | ||
|
|
@@ -333,6 +334,55 @@ def test_get_stored_procedures(self): | |
| self.assertEqual(len(results), 1) | ||
| self.assertEqual(results[0].name, "sp_include") | ||
|
|
||
|
|
||
| class TestUpdateMssqlIschemaNames: | ||
| """Verify update_mssql_ischema_names mutates the dict in-place and returns None.""" | ||
|
|
||
| EXPECTED_MSSQL_TYPES = [ | ||
| "nvarchar", | ||
| "nchar", | ||
| "ntext", | ||
| "bit", | ||
| "image", | ||
| "binary", | ||
| "smallmoney", | ||
| "money", | ||
| "real", | ||
| "smalldatetime", | ||
| "datetime2", | ||
| "datetimeoffset", | ||
| "sql_variant", | ||
| "uniqueidentifier", | ||
| "xml", | ||
| "hierarchyid", | ||
| "geography", | ||
| "geometry", | ||
| ] | ||
|
|
||
| def test_returns_none(self): | ||
| result = update_mssql_ischema_names({}) | ||
| assert result is None | ||
|
|
||
| def test_mutates_dict_in_place(self): | ||
| target = {} | ||
| update_mssql_ischema_names(target) | ||
| for type_key in self.EXPECTED_MSSQL_TYPES: | ||
| assert ( | ||
| type_key in target | ||
| ), f"'{type_key}' was not added by update_mssql_ischema_names" | ||
|
|
||
| def test_all_added_types_are_not_none(self): | ||
| target = {} | ||
| update_mssql_ischema_names(target) | ||
| for type_key in self.EXPECTED_MSSQL_TYPES: | ||
| assert target[type_key] is not None, f"'{type_key}' was mapped to None" | ||
|
|
||
| def test_does_not_overwrite_existing_entries(self): | ||
| sentinel = object() | ||
| target = {"existing_key": sentinel} | ||
| update_mssql_ischema_names(target) | ||
| assert target["existing_key"] is sentinel | ||
|
gitar-bot[bot] marked this conversation as resolved.
Comment on lines
+380
to
+384
|
||
|
|
||
| @patch( | ||
| "metadata.ingestion.source.database.mssql.connection.test_connection_db_common" | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.