def is_foreign_expr(self, expr): from ibis.expr.analysis import ExprValidator # The expression isn't foreign to us. For example, the parent table set # in a correlated WHERE subquery if self.has_ref(expr, parent_contexts=True): return False exprs = [self.query.table_set] + self.query.select_set validator = ExprValidator(exprs) return not validator.validate(expr)
def __init__(self, table_expr, proj_exprs): from ibis.expr.analysis import ExprValidator # Need to validate that the column expressions are compatible with the # input table; this means they must either be scalar expressions or # array expressions originating from the same root table expression validator = ExprValidator([table_expr]) # Resolve schema and initialize types = [] names = [] clean_exprs = [] for expr in proj_exprs: if isinstance(expr, py_string): expr = table_expr[expr] validator.assert_valid(expr) if isinstance(expr, ValueExpr): name = expr.get_name() names.append(name) types.append(expr.type()) elif rules.is_table(expr): schema = expr.schema() names.extend(schema.names) types.extend(schema.types) else: raise NotImplementedError clean_exprs.append(expr) # validate uniqueness schema = ir.Schema(names, types) HasSchema.__init__(self, schema) Node.__init__(self, [table_expr] + [clean_exprs]) self.table = table_expr self.selections = clean_exprs
def __init__(self, left, right, join_predicates): from ibis.expr.analysis import ExprValidator if not rules.is_table(left): raise TypeError('Can only join table expressions, got %s for ' 'left table' % type(left)) if not rules.is_table(right): raise TypeError('Can only join table expressions, got %s for ' 'right table' % type(left)) if left.equals(right): right = right.view() self.left = left self.right = right self.predicates = self._clean_predicates(join_predicates) # Validate join predicates. Each predicate must be valid jointly when # considering the roots of each input table validator = ExprValidator([self.left, self.right]) validator.validate_all(self.predicates) Node.__init__(self, [self.left, self.right, self.predicates])
def _assert_valid(self, exprs): from ibis.expr.analysis import ExprValidator ExprValidator([self]).validate_all(exprs)