Skip to content

Commit

Permalink
fix(datafusion): work around lack of support for uppercase units in i…
Browse files Browse the repository at this point in the history
…ntervals
  • Loading branch information
cpcloud committed Jan 1, 2024
1 parent 8ae57ff commit ebb6cde
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ibis/backends/datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
_exclude_exp = (exp.Pow, exp.ArrayContains)


def _lower_unit(self, expr):
value = expr.this.sql(dialect=self.dialect)
unit = expr.unit.this.lower()
return f"INTERVAL '{value} {unit}'"


# the DataFusion dialect was created to skip the power function to operator transformation
# in the future this could be used to optimize sqlglot for datafusion
class DataFusion(Postgres):
Expand All @@ -61,6 +67,7 @@ class Generator(Postgres.Generator):
]
),
exp.IsNan: rename_func("isnan"),
exp.Interval: _lower_unit,
}


Expand Down

0 comments on commit ebb6cde

Please sign in to comment.