Skip to content

Commit

Permalink
fix(duckdb): ensure that parameter names are unlikely to overlap with…
Browse files Browse the repository at this point in the history
… column names
  • Loading branch information
cpcloud authored and kszucs committed Dec 14, 2023
1 parent 424c973 commit d93dbe2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 5 additions & 3 deletions ibis/backends/duckdb/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _array_filter(t, op):


def _array_intersect(t, op):
name = "x"
name = "__array_filter_param__"
parameter = ops.Argument(
name=name, shape=op.left.shape, dtype=op.left.dtype.value_type
)
Expand Down Expand Up @@ -423,10 +423,12 @@ def _to_json_collection(t, op):
t,
ops.ArrayFilter(
op.arg,
param="x",
param="__array_filter_param__",
body=ops.NotEquals(
ops.Argument(
name="x", shape=op.arg.shape, dtype=op.arg.dtype.value_type
name="__array_filter_param__",
shape=op.arg.shape,
dtype=op.arg.dtype.value_type,
),
op.other,
),
Expand Down
10 changes: 7 additions & 3 deletions ibis/expr/types/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ def map(self, func: Callable[[ir.Value], ir.Value]) -> ir.ArrayValue:
│ [] │
└────────────────────────┘
"""
param = next(iter(inspect.signature(func).parameters.keys()))
name = next(iter(inspect.signature(func).parameters.keys()))
param = f"__array_map_param_{name}__"
parameter = ops.Argument(
name=param, shape=self.op().shape, dtype=self.type().value_type
).to_expr()
Expand Down Expand Up @@ -502,9 +503,12 @@ def filter(
│ [] │
└───────────────────────────────┘
"""
param = next(iter(inspect.signature(predicate).parameters.keys()))
name = next(iter(inspect.signature(predicate).parameters.keys()))
param = f"__array_filter_param_{name}__"
parameter = ops.Argument(
name=param, shape=self.op().shape, dtype=self.type().value_type
name=param,
shape=self.op().shape,
dtype=self.type().value_type,
).to_expr()
return ops.ArrayFilter(self, param=param, body=predicate(parameter)).to_expr()

Expand Down

0 comments on commit d93dbe2

Please sign in to comment.