Skip to content

Commit

Permalink
fix(polars): backwards compatibility for the time_zone and `time_un…
Browse files Browse the repository at this point in the history
…it` properties
  • Loading branch information
cpcloud committed Apr 10, 2023
1 parent 103a008 commit 3a2c4df
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ibis/backends/polars/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,20 @@ def to_ibis_dtype(typ):

@to_ibis_dtype.register(pl.Datetime)
def from_polars_datetime(typ):
return dt.Timestamp(timezone=typ.tz)
try:
timezone = typ.time_zone
except AttributeError: # pragma: no cover
timezone = typ.tz # pragma: no cover
return dt.Timestamp(timezone=timezone)


@to_ibis_dtype.register(pl.Duration)
def from_polars_duration(typ):
return dt.Interval(unit=typ.tu)
try:
time_unit = typ.time_unit
except AttributeError: # pragma: no cover
time_unit = typ.tu # pragma: no cover
return dt.Interval(unit=time_unit)


@to_ibis_dtype.register(pl.List)
Expand Down

0 comments on commit 3a2c4df

Please sign in to comment.