Skip to content

Commit

Permalink
refactor(analysis): remove is_analytic function in favor of `node.f…
Browse files Browse the repository at this point in the history
…ind()`
  • Loading branch information
kszucs authored and cpcloud committed Aug 7, 2023
1 parent c4658e7 commit 0452810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 0 additions & 10 deletions ibis/expr/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,16 +628,6 @@ def predicate(node):
return list(g.traverse(predicate, node))


def is_analytic(node):
def predicate(node):
if isinstance(node, (ops.Reduction, ops.Analytic)):
return g.halt, True
else:
return g.proceed, None

return any(g.traverse(predicate, node))


def is_reduction(node):
"""Check whether an expression contains a reduction or not.
Expand Down
10 changes: 4 additions & 6 deletions ibis/expr/operations/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import ibis.expr.rules as rlz
from ibis.common.patterns import CoercionError
from ibis.common.typing import VarTuple # noqa: TCH001
from ibis.expr.operations.analytic import Analytic
from ibis.expr.operations.core import Column, Value
from ibis.expr.operations.generic import Literal
from ibis.expr.operations.numeric import Negate
from ibis.expr.operations.reductions import Reduction
from ibis.expr.operations.relations import Relation # noqa: TCH001
from ibis.expr.operations.sortkeys import SortKey # noqa: TCH001

Expand Down Expand Up @@ -127,13 +129,9 @@ class WindowFunction(Value):
shape = ds.columnar

def __init__(self, func, frame):
from ibis.expr.analysis import (
is_analytic,
propagate_down_window,
shares_all_roots,
)
from ibis.expr.analysis import propagate_down_window, shares_all_roots

if not is_analytic(func):
if not func.find((Reduction, Analytic)):
raise com.IbisTypeError("Window function expression must be analytic")

func = propagate_down_window(func, frame)
Expand Down

0 comments on commit 0452810

Please sign in to comment.