Skip to content

Commit f55b310

Browse files
committed
Address support on postgresql
1 parent 4c85cd9 commit f55b310

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/mustela/translation/optimizer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ def fold_case(self, expr: ibis.Value | ibis.Deferred) -> ibis.Value:
174174
else:
175175
return op.default.to_expr()
176176
elif len(op.cases) == 1 and results_are_literals and possible_values == {1, 0}:
177-
# results are 1 or 0, we can fold it to a boolean
178-
# expression.
177+
# results are 1 or 0, we can fold it to a boolean expression.
178+
# FIXME: This doesn't work on postgresql so we need to disable it for the moment.
179+
return expr
179180
if op.results[0].value == 1:
180181
return (op.cases[0].to_expr()).cast("float64")
181182
else:

src/mustela/translation/steps/onehotencoder.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ def process(self) -> None:
3232
raise ValueError("OneHotEncoder: input expression not found")
3333

3434
casted_variables = [
35-
self._optimizer.fold_cast(
36-
typing.cast(ibis.expr.types.BooleanValue, (input_expr == cat)).cast(
37-
"int"
38-
)
39-
).name(self.variable_unique_short_alias("onehot"))
35+
ibis.ifelse(input_expr == cat, 1.0, 0.0).name(
36+
self.variable_unique_short_alias("onehot")
37+
)
4038
for cat in cats
4139
]
4240

0 commit comments

Comments
 (0)