Skip to content
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

feat(sql): load parsed but unsupported types as unknown #9868

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ibis/backends/sql/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@

if method := getattr(cls, f"_from_sqlglot_{typecode.name}", None):
dtype = method(*typ.expressions)
elif (known_typ := _from_sqlglot_types.get(typecode)) is not None:
dtype = known_typ(nullable=cls.default_nullable)
else:
dtype = _from_sqlglot_types[typecode](nullable=cls.default_nullable)
dtype = dt.unknown

Check warning on line 175 in ibis/backends/sql/datatypes.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/sql/datatypes.py#L175

Added line #L175 was not covered by tests

if nullable is not None:
return dtype.copy(nullable=nullable)
Expand Down
24 changes: 23 additions & 1 deletion ibis/backends/sql/tests/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import ibis.common.exceptions as com
import ibis.expr.datatypes as dt
import ibis.tests.strategies as its
from ibis.backends.sql.datatypes import DuckDBType, PostgresType, SqlglotType
from ibis.backends.sql.datatypes import (
ClickHouseType,
DuckDBType,
PostgresType,
SqlglotType,
)


def assert_dtype_roundtrip(ibis_type, sqlglot_expected=None):
Expand Down Expand Up @@ -63,3 +68,20 @@
SqlglotType.from_string("INTERVAL")
assert PostgresType.from_string("INTERVAL") == dt.Interval("s")
assert DuckDBType.from_string("INTERVAL") == dt.Interval("us")


@pytest.mark.parametrize(
"typ",
[
sge.DataType.Type.UINT256,
sge.DataType.Type.UINT128,
sge.DataType.Type.BIGSERIAL,
sge.DataType.Type.HLLSKETCH,
],
)
@pytest.mark.parametrize(
"typengine",
[ClickHouseType, PostgresType, DuckDBType],
)
def test_unsupported_dtypes_are_unknown(typengine, typ):
assert typengine.to_ibis(sge.DataType(this=typ)) == dt.unknown

Check warning on line 87 in ibis/backends/sql/tests/test_datatypes.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/sql/tests/test_datatypes.py#L87

Added line #L87 was not covered by tests