Skip to content

Commit

Permalink
fix(rewrites): add missing filter arguments for node.replace() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs authored and cpcloud committed Jan 3, 2024
1 parent 7d485c1 commit 1638630
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ibis/backends/base/sqlglot/rewrites.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def merge_select_select(_):
if v.find((Window, ops.Unnest), filter=ops.Value):
return _
for v in _.predicates:
if v.find(ops.ExistsSubquery, filter=ops.Value):
if v.find((ops.ExistsSubquery, ops.InSubquery), filter=ops.Value):
return _

subs = {ops.Field(_.parent, k): v for k, v in _.parent.values.items()}
selections = {k: v.replace(subs) for k, v in _.selections.items()}
selections = {k: v.replace(subs, filter=ops.Value) for k, v in _.selections.items()}
predicates = tuple(p.replace(subs, filter=ops.Value) for p in _.predicates)
sort_keys = tuple(s.replace(subs) for s in _.sort_keys)
sort_keys = tuple(s.replace(subs, filter=ops.Value) for s in _.sort_keys)

return Select(
_.parent.parent,
Expand Down
8 changes: 4 additions & 4 deletions ibis/expr/rewrites.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,25 +254,25 @@ def complete_reprojection(_, y):
@replace(p.Project(y @ p.Project))
def subsequent_projects(_, y):
rule = p.Field(y, name) >> Item(y.values, name)
values = {k: v.replace(rule) for k, v in _.values.items()}
values = {k: v.replace(rule, filter=ops.Value) for k, v in _.values.items()}
return ops.Project(y.parent, values)


@replace(p.Filter(y @ p.Filter))
def subsequent_filters(_, y):
rule = p.Field(y, name) >> d.Field(y.parent, name)
preds = tuple(v.replace(rule) for v in _.predicates)
preds = tuple(v.replace(rule, filter=ops.Value) for v in _.predicates)
return ops.Filter(y.parent, y.predicates + preds)


@replace(p.Filter(y @ p.Project))
def reorder_filter_project(_, y):
rule = p.Field(y, name) >> Item(y.values, name)
preds = tuple(v.replace(rule) for v in _.predicates)
preds = tuple(v.replace(rule, filter=ops.Value) for v in _.predicates)

inner = ops.Filter(y.parent, preds)
rule = p.Field(y.parent, name) >> d.Field(inner, name)
projs = {k: v.replace(rule) for k, v in y.values.items()}
projs = {k: v.replace(rule, filter=ops.Value) for k, v in y.values.items()}

return ops.Project(inner, projs)

Expand Down

0 comments on commit 1638630

Please sign in to comment.