def filter(table, predicates): """ Select rows from table based on boolean expressions Parameters ---------- predicates : boolean array expressions, or list thereof Returns ------- filtered_expr : TableExpr """ if isinstance(predicates, Expr): predicates = _L.unwrap_ands(predicates) predicates = util.promote_list(predicates) predicates = [ir.bind_expr(table, x) for x in predicates] resolved_predicates = [] for pred in predicates: if isinstance(pred, ir.AnalyticExpr): pred = pred.to_filter() resolved_predicates.append(pred) op = _L.apply_filter(table, resolved_predicates) return TableExpr(op)
def _resolve_predicates(table, predicates): if isinstance(predicates, Expr): predicates = _L.unwrap_ands(predicates) predicates = util.promote_list(predicates) predicates = [ir.bind_expr(table, x) for x in predicates] resolved_predicates = [] for pred in predicates: if isinstance(pred, ir.AnalyticExpr): pred = pred.to_filter() resolved_predicates.append(pred) return resolved_predicates
def _rewrite_exprs(self, what): from ibis.expr.analysis import substitute_parents what = util.promote_list(what) all_exprs = [] for expr in what: if isinstance(expr, ir.ExprList): all_exprs.extend(expr.exprs()) else: bound_expr = ir.bind_expr(self.table, expr) all_exprs.append(bound_expr) return [substitute_parents(x, past_projection=False) for x in all_exprs]
def _rewrite_exprs(self, what): from ibis.expr.analysis import substitute_parents what = util.promote_list(what) all_exprs = [] for expr in what: if isinstance(expr, ir.ExprList): all_exprs.extend(expr.exprs()) else: bound_expr = ir.bind_expr(self.table, expr) all_exprs.append(bound_expr) return [ substitute_parents(x, past_projection=False) for x in all_exprs ]