def _check_literal_promote_cases(self, op, cases): for name, val, ex_type in cases: col = self.table[name] result = op(col, val) ex_class = ir.array_type(ex_type) assert isinstance(result, ex_class) result = op(val, col) ex_class = ir.array_type(ex_type) assert isinstance(result, ex_class)
def test_string_to_number(self): types = ['int8', 'int32', 'double', 'float'] for t in types: c = 'g' casted = self.table[c].cast(t) assert isinstance(casted, ir.array_type(t)) casted_literal = ibis.literal('5').cast(t).name('bar') assert isinstance(casted_literal, ir.scalar_type(t)) assert casted_literal.get_name() == 'bar'
def test_string_to_number(self): types = ["int8", "int32", "double", "float"] for t in types: c = "g" casted = self.table[c].cast(t) assert isinstance(casted, ir.array_type(t)) casted_literal = ibis.literal("5").cast(t).name("bar") assert isinstance(casted_literal, ir.scalar_type(t)) assert casted_literal.get_name() == "bar"
def test_getitem_column_select(self): for k, v in self.schema_dict.iteritems(): col = self.table[k] # Make sure it's the right type assert isinstance(col, ArrayExpr) assert isinstance(col, ir.array_type(v)) # Ensure we have a field selection with back-reference to the table parent = col.parent() assert isinstance(parent, ops.TableColumn) assert parent.parent() is self.table
def to_expr(self): ctype = self.table._get_type(self.name) klass = ir.array_type(ctype) return klass(self, name=self.name)
def shape_like_args(args, out_type): if util.any_of(args, ir.ArrayExpr): return ir.array_type(out_type) else: return ir.scalar_type(out_type)
def shape_like(arg, out_type): if isinstance(arg, ir.ScalarExpr): return ir.scalar_type(out_type) else: return ir.array_type(out_type)