コード例 #1
0
    def compile(self):
        from ibis.expr.api import schema

        buf = StringIO()
        buf.write(self._create_line())

        def _push_schema(x):
            formatted = format_schema(x)
            buf.write('{0}'.format(formatted))

        if self.partition is not None:
            modified_schema = []
            partition_schema = []
            for name, dtype in zip(self.schema.names, self.schema.types):
                if name in self.partition:
                    partition_schema.append((name, dtype))
                else:
                    modified_schema.append((name, dtype))

            buf.write('\n')
            _push_schema(schema(modified_schema))
            buf.write('\nPARTITIONED BY ')
            _push_schema(schema(partition_schema))
        else:
            buf.write('\n')
            _push_schema(self.schema)

        format_ddl = self.table_format.to_ddl()
        if format_ddl:
            buf.write(format_ddl)

        buf.write(self._location())

        return buf.getvalue()
コード例 #2
0
ファイル: ddl.py プロジェクト: megvuyyuru/ibis
    def compile(self):
        from ibis.expr.api import schema

        buf = BytesIO()
        buf.write(self._create_line())

        def _push_schema(x):
            formatted = format_schema(x)
            buf.write('{0}'.format(formatted))

        if self.partition is not None:
            modified_schema = []
            partition_schema = []
            for name, dtype in zip(self.schema.names, self.schema.types):
                if name in self.partition:
                    partition_schema.append((name, dtype))
                else:
                    modified_schema.append((name, dtype))

            buf.write('\n')
            _push_schema(schema(modified_schema))
            buf.write('\nPARTITIONED BY ')
            _push_schema(schema(partition_schema))
        else:
            buf.write('\n')
            _push_schema(self.schema)

        format_ddl = self.table_format.to_ddl()
        if format_ddl:
            buf.write(format_ddl)

        buf.write(self._location())

        return buf.getvalue()
コード例 #3
0
ファイル: pandas_interop.py プロジェクト: Jackson1992/ibis
def pandas_to_ibis_schema(frame):
    from ibis.expr.api import schema
    # no analog for decimal in pandas
    pairs = []
    for col_name in frame:
        ibis_type = pandas_col_to_ibis_type(frame[col_name])
        pairs.append((col_name, ibis_type))
    return schema(pairs)
コード例 #4
0
ファイル: pandas_interop.py プロジェクト: chris-b1/ibis
def pandas_to_ibis_schema(frame):
    from ibis.expr.api import schema
    # no analog for decimal in pandas
    pairs = []
    for col_name in frame:
        ibis_type = pandas_col_to_ibis_type(frame[col_name])
        pairs.append((col_name, ibis_type))
    return schema(pairs)
コード例 #5
0
ファイル: test_table.py プロジェクト: sanjc/ibis
def test_column_relabel(table):
    # GH #551. Keeping the test case very high level to not presume that
    # the relabel is necessarily implemented using a projection
    types = ['int32', 'string', 'double']
    table = api.table(zip(['foo', 'bar', 'baz'], types))
    result = table.relabel({'foo': 'one', 'baz': 'three'})

    schema = result.schema()
    ex_schema = api.schema(zip(['one', 'bar', 'three'], types))
    assert_equal(schema, ex_schema)
コード例 #6
0
ファイル: test_table.py プロジェクト: Vicky-leilei/ibis
    def test_column_relabel(self):
        # GH #551. Keeping the test case very high level to not presume that
        # the relabel is necessarily implemented using a projection
        types = ['int32', 'string', 'double']
        table = api.table(zip(['foo', 'bar', 'baz'], types))
        result = table.relabel({'foo': 'one', 'baz': 'three'})

        schema = result.schema()
        ex_schema = api.schema(zip(['one', 'bar', 'three'], types))
        assert_equal(schema, ex_schema)
コード例 #7
0
def schema_kudu_to_ibis(kschema, drop_nn=False):
    ibis_types = []
    for i in range(len(kschema)):
        col = kschema[i]

        typeclass = _kudu_type_to_ibis_typeclass[col.type.name]

        if drop_nn:
            # For testing, because Impala does not have nullable types
            itype = typeclass(True)
        else:
            itype = typeclass(col.nullable)

        ibis_types.append((col.name, itype))

    return schema(ibis_types)
コード例 #8
0
ファイル: kudu_support.py プロジェクト: deepfield/ibis
def schema_kudu_to_ibis(kschema, drop_nn=False):
    ibis_types = []
    for i in range(len(kschema)):
        col = kschema[i]

        typeclass = _kudu_type_to_ibis_typeclass[col.type.name]

        if drop_nn:
            # For testing, because Impala does not have nullable types
            itype = typeclass(True)
        else:
            itype = typeclass(col.nullable)

        ibis_types.append((col.name, itype))

    return schema(ibis_types)