Beispiel #1
0
 def __init__(self, tree: Node):
     if tree.get_child(0).get_type() == TK.TOK_FUNCTION:
         self.selexpr = FunctionXpr(tree.get_child(0))
     else:
         self.selexpr = parse_value(tree.get_child(0))
     if tree.get_children_count() == 2:
         self.alias = parse_value(tree.get_child(1))
Beispiel #2
0
def parse_tok_limit(tree: Node):
    _from = 0
    _size = 0

    if tree.get_children_count() == 2:
        _from = tree.get_child(0).get_value()
        _size = tree.get_child(1).get_value()
    else:
        _from = 0
        _size = tree.get_child(0).get_value()
    return (_from, _size)
Beispiel #3
0
def bucket_function(tree: Node, _size):
    bucket = {}
    bucket[tree.get_value()] = {}
    for i in range(0, tree.get_children_count()):
        if tree.get_child(i).get_type() == TK.TOK_DICT:
            bucket[tree.get_value()].update(parse_object(tree.get_child(i)))
    if _size != -1:
        bucket[tree.get_value()]['size'] = _size
    aggs = {"aggs": {}}
    field = bucket[tree.get_value()]['field']
    aggs['aggs'][field] = bucket
    return (field, aggs)