def schema_from_table(table):
    # Convert SQLA table to Ibis schema
    names = table.columns.keys()

    types = []
    for c in table.columns.values():
        type_class = type(c.type)

        if isinstance(c.type, sa.types.NUMERIC):
            t = dt.Decimal(c.type.precision,
                           c.type.scale,
                           nullable=c.nullable)
        else:
            if c.type in _sqla_type_to_ibis:
                ibis_class = _sqla_type_to_ibis[c.type]
            elif type_class in _sqla_type_to_ibis:
                ibis_class = _sqla_type_to_ibis[type_class]
            else:
                raise NotImplementedError(c.type)
            t = ibis_class(c.nullable)

        types.append(t)

    return dt.Schema(names, types)
dataset/ETHPy150Open cloudera/ibis/ibis/sql/alchemy.py/schema_from_table/original