Example #1
0
    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)
Example #2
0
    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'
Example #3
0
    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"
Example #4
0
    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
Example #5
0
    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
Example #6
0
 def to_expr(self):
     ctype = self.table._get_type(self.name)
     klass = ir.array_type(ctype)
     return klass(self, name=self.name)
Example #7
0
 def to_expr(self):
     ctype = self.table._get_type(self.name)
     klass = ir.array_type(ctype)
     return klass(self, name=self.name)
Example #8
0
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)
Example #9
0
def shape_like(arg, out_type):
    if isinstance(arg, ir.ScalarExpr):
        return ir.scalar_type(out_type)
    else:
        return ir.array_type(out_type)