Ejemplo n.º 1
0
def format_cube_from_aggop(decoders, aggs, start, query, select):
    agg = drill(aggs)
    matricies = [(s, Matrix(dims=[], zeros=s.default)) for s in select]
    for s, m in matricies:
        m[tuple()] = _pull(s, agg)
    cube = Cube(query.select, [], {s.name: m for s, m in matricies})
    cube.frum = query
    return cube
Ejemplo n.º 2
0
def format_table_from_aggop(decoders, aggs, start, query, select):
    header = select.name
    agg = drill(aggs)
    row = []
    for s in select:
        row.append(_pull(s, agg))

    return Data(meta={"format": "table"}, header=header, data=[row])
Ejemplo n.º 3
0
def format_cube_from_aggop(decoders, aggs, start, query, select):
    agg = drill(aggs)
    matricies = [(s, Matrix(dims=[], zeros=s.default)) for s in select]
    for s, m in matricies:
        m[tuple()] = _pull(s, agg)
    cube = Cube(query.select, [], {s.name: m for s, m in matricies})
    cube.frum = query
    return cube
Ejemplo n.º 4
0
def format_cube_from_aggop(decoders, aggs, start, query, select):
    agg = drill(aggs)
    matricies = [(s, Matrix(dims=[], zeros=(s.aggregate == "count"))) for s in select]
    for s, m in matricies:
        m[tuple()] = agg[s.pull]
    cube = Cube(query.select, [], {s.name: m for s, m in matricies})
    cube.frum = query
    return cube
Ejemplo n.º 5
0
def format_table_from_aggop(decoders, aggs, start, query, select):
    header = select.name
    agg = drill(aggs)
    row = []
    for s in select:
        row.append(_pull(s, agg))

    return Data(
        meta={"format": "table"},
        header=header,
        data=[row]
    )
Ejemplo n.º 6
0
def format_list_from_aggop(decoders, aggs, start, query, select):
    agg = drill(aggs)

    if isinstance(query.select, list):
        item = Data()
        for s in select:
            item[s.name] = _pull(s, agg)
    else:
        item = _pull(select[0], agg)

    if query.edges or query.groupby:
        return wrap({"meta": {"format": "list"}, "data": [item]})
    else:
        return wrap({"meta": {"format": "value"}, "data": item})
Ejemplo n.º 7
0
def format_table_from_aggop(decoders, aggs, start, query, select):
    header = select.name
    agg = drill(aggs)
    row = []
    for s in select:
        if not s.pull:
            Log.error("programmer error")
        row.append(agg[s.pull])

    return Dict(
        meta={"format": "table"},
        header=header,
        data=[row]
    )
Ejemplo n.º 8
0
def format_list_from_aggop(decoders, aggs, start, query, select):
    agg = drill(aggs)

    if isinstance(query.select, list):
        item = Data()
        for s in select:
            item[s.name] = _pull(s, agg)
    else:
        item = _pull(select[0], agg)

    if query.edges or query.groupby:
        return wrap({
            "meta": {"format": "list"},
            "data": [item]
        })
    else:
        return wrap({
            "meta": {"format": "value"},
            "data": item
        })