Skip to content

Commit dc37796

Browse files
authored
fix(datatype): convert from sqlglot VARCHAR(MAX) correctly (#11202)
1 parent ccd9359 commit dc37796

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

ibis/backends/sql/datatypes.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,29 @@ def _from_sqlglot_VARCHAR(
220220
nullable=nullable,
221221
)
222222

223-
_from_sqlglot_NVARCHAR = _from_sqlglot_NCHAR = _from_sqlglot_CHAR = (
224-
_from_sqlglot_FIXEDSTRING
225-
) = _from_sqlglot_VARCHAR
223+
@classmethod
224+
def _from_sqlglot_NVARCHAR(
225+
cls, length: sge.DataTypeParam | None = None, nullable: bool | None = None
226+
) -> dt.String:
227+
return cls._from_sqlglot_VARCHAR(length, nullable=nullable)
228+
229+
@classmethod
230+
def _from_sqlglot_NCHAR(
231+
cls, length: sge.DataTypeParam | None = None, nullable: bool | None = None
232+
) -> dt.String:
233+
return cls._from_sqlglot_VARCHAR(length, nullable=nullable)
234+
235+
@classmethod
236+
def _from_sqlglot_CHAR(
237+
cls, length: sge.DataTypeParam | None = None, nullable: bool | None = None
238+
) -> dt.String:
239+
return cls._from_sqlglot_VARCHAR(length, nullable=nullable)
240+
241+
@classmethod
242+
def _from_sqlglot_FIXEDSTRING(
243+
cls, length: sge.DataTypeParam | None = None, nullable: bool | None = None
244+
) -> dt.String:
245+
return cls._from_sqlglot_VARCHAR(length, nullable=nullable)
226246

227247
@classmethod
228248
def _from_sqlglot_MAP(
@@ -466,6 +486,10 @@ def _from_ibis_SpecificGeometry(cls, dtype: dt.GeoSpatial):
466486
this = getattr(typecode, dtype.geotype.upper())
467487
return sge.DataType(this=this, expressions=expressions)
468488

489+
# warning: this does early binding, so if you call eg `PostgresType._from_ibis_Point`
490+
# this will resolve to `SqlglotType._from_ibis_SpecificGeometry`, not
491+
# `PostgresType._from_ibis_SpecificGeometry`.
492+
# At this point, not a problem, but be careful if you override this in subclasses.
469493
_from_ibis_Point = _from_ibis_LineString = _from_ibis_Polygon = (
470494
_from_ibis_MultiLineString
471495
) = _from_ibis_MultiPoint = _from_ibis_MultiPolygon = _from_ibis_SpecificGeometry

0 commit comments

Comments
 (0)