Skip to content

Commit

Permalink
revert: feat(dtypes): fall back to dt.unknown for unknown types (#9569
Browse files Browse the repository at this point in the history
)
  • Loading branch information
gforsyth authored Jul 13, 2024
1 parent 0ff595e commit 63b3cac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ibis/backends/sql/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ def to_ibis(cls, typ: sge.DataType, nullable: bool | None = None) -> dt.DataType
if method := getattr(cls, f"_from_sqlglot_{typecode.name}", None):
dtype = method(*typ.expressions)
else:
dtype = _from_sqlglot_types.get(typecode, dt.unknown)(
nullable=cls.default_nullable
)
dtype = _from_sqlglot_types[typecode](nullable=cls.default_nullable)

if nullable is not None:
return dtype.copy(nullable=nullable)
Expand Down Expand Up @@ -419,6 +417,8 @@ class PostgresType(SqlglotType):

unknown_type_strings = FrozenDict(
{
"vector": dt.unknown,
"tsvector": dt.unknown,
"line": dt.linestring,
"line[]": dt.Array(dt.linestring),
"polygon": dt.polygon,
Expand Down Expand Up @@ -454,6 +454,16 @@ def _from_ibis_Map(cls, dtype: dt.Map) -> sge.DataType:
raise com.IbisTypeError("Postgres only supports string values in maps")
return sge.DataType(this=typecode.HSTORE)

@classmethod
def from_string(cls, text: str, nullable: bool | None = None) -> dt.DataType:
if text.lower().startswith("vector"):
text = "vector"
if dtype := cls.unknown_type_strings.get(text.lower()):
return dtype

sgtype = sg.parse_one(text, into=sge.DataType, read=cls.dialect)
return cls.to_ibis(sgtype, nullable=nullable)


class RisingWaveType(PostgresType):
dialect = "risingwave"
Expand Down

0 comments on commit 63b3cac

Please sign in to comment.