-
Notifications
You must be signed in to change notification settings - Fork 704
Description
What happened?
The MSSQL backend fails when the query result contains a user-defined type (UDT). When I use .sql() on the mssql backend:
ibis.mssql.connect(...).sql('SELECT someFieldWithUDTResult FROM someTable')exception 'NoneType' object has no attribute 'lower' is thrown. This occurs because .sql() tries to resolve the schema using mssql._get_schema_using_query() using this statement:
ibis/ibis/backends/mssql/__init__.py
Lines 336 to 347 in d9402b4
| query = f""" | |
| SELECT | |
| name, | |
| is_nullable, | |
| system_type_name, | |
| precision, | |
| scale, | |
| error_number, | |
| error_message | |
| FROM sys.dm_exec_describe_first_result_set(N{tsql}, NULL, 0) | |
| ORDER BY column_ordinal | |
| """ # noqa: S608 |
relying on the system_type_name column from sys.dm_exec_describe_first_result_set. According to Microsoft documentation, system_type_name returns NULL for user-defined types. When this None value is passed to the SQL compiler TypeMapper, it results in the exception when
ibis/ibis/backends/sql/datatypes.py
Lines 182 to 184 in d9402b4
| def from_string(cls, text: str, nullable: bool | None = None) -> dt.DataType: | |
| if dtype := cls.unknown_type_strings.get(text.lower()): | |
| return dtype |
calls text.lower() but text is None.
What version of ibis are you using?
10.8.0
What backend(s) are you using, if any?
MSSQL
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status