MCPcopy Create free account
hub / github.com/dask/dask / _check_dependents_are_predicates

Function _check_dependents_are_predicates

dask/dataframe/dask_expr/_expr.py:4063–4101  ·  view source on GitHub ↗
(
    expr, other_names, parent: Expr, dependents, allow_reduction=True
)

Source from the content-addressed store, hash-verified

4061
4062
4063def _check_dependents_are_predicates(
4064 expr, other_names, parent: Expr, dependents, allow_reduction=True
4065):
4066 # singleton approach should make this easier
4067
4068 # Walk down the predicate side from the filter to see if we can arrive at
4069 # other_names without hitting an expression that has other dependents that
4070 # are not part of the predicate, see test_filter_pushdown_unavailable
4071 allowed_expressions = {parent._name}
4072 stack = parent.dependencies()
4073 seen = set()
4074 all_dependents = set()
4075
4076 while stack:
4077 e = stack.pop()
4078 if expr._name == e._name:
4079 continue
4080
4081 if e._name in seen:
4082 continue
4083 seen.add(e._name)
4084
4085 if isinstance(e, _DelayedExpr):
4086 continue
4087
4088 all_dependents.update(
4089 {x()._name for x in dependents[e._name] if x() is not None}
4090 )
4091
4092 if not allow_reduction:
4093 if isinstance(e, (ApplyConcatApply, TreeReduce, ShuffleReduce)):
4094 return False
4095
4096 allowed_expressions.add(e._name)
4097 stack.extend(e.dependencies())
4098
4099 return all_dependents.issubset(allowed_expressions) and other_names.issubset(
4100 allowed_expressions
4101 )
4102
4103
4104def calc_divisions_for_align(*exprs, allow_shuffle=True):

Callers 1

Calls 4

setClass · 0.85
popMethod · 0.80
dependenciesMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected