Skip to content

Commit

Permalink
refactor: remove expr arguments in translate
Browse files Browse the repository at this point in the history
This removes all usage of `expr` being passed explicitly to mapping
functions.  There are a few cases where Ibis 3.x will pass in
expressions still, but those should be handled by the `_expr` rule,
which forwards on the `op` (at a cost of an extra dispatch).

There are also a few bits where we do reductions on predicates that
operate on expressions.  Those should be converted to ops where
possible (without breaking support for older Ibis versions).
  • Loading branch information
gforsyth committed Apr 24, 2023
1 parent ce27195 commit 99649dc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 89 deletions.
12 changes: 3 additions & 9 deletions ibis_substrait/compiler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,21 @@ def __init__(self, udf_uri: str | None = None) -> None:

def function_id(
self,
*,
expr: ir.ValueExpr | None = None,
op: ops.Value | None = None,
op: ops.Value,
) -> int:
"""Create a function mapping for a given expression.
Parameters
----------
expr
An ibis expression that produces a value.
op
Passthrough op to directly specify desired substrait scalar function
Ibis operation to use to lookup desired substrait scalar function
Returns
-------
ste.ExtensionsFunctionId
This is a unique identifier for a given operation type, *argument
types N-tuple.
"""
if op is None:
op = expr.op() if expr is not None else None
op_type = type(op)
op_name = IBIS_SUBSTRAIT_OP_MAPPING[op_type.__name__]

Expand Down Expand Up @@ -196,7 +190,7 @@ def compile(self, expr: ir.TableExpr, **kwargs: Any) -> stp.Plan:
expr_schema = expr.schema()
rel = stp.PlanRel(
root=stalg.RelRoot(
input=translate(expr.op(), expr=expr, compiler=self, **kwargs),
input=translate(expr.op(), compiler=self, **kwargs),
names=translate(expr_schema).names,
)
)
Expand Down
Loading

0 comments on commit 99649dc

Please sign in to comment.