Beispiel #1
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)
Beispiel #2
0
 def __init__(self, tree: Node):
     self.compare = tree.get_value().lower()
     if tree.get_child(0).get_type() == TK.TOK_EXPRESSION_LEFT:
         self.left_values = parse_left_values(
             tree.get_child(0).get_children())
     if tree.get_child(1).get_type() == TK.TOK_EXPRESSION_RIGHT:
         self.right_value = parse_value(tree.get_child(1).get_child(0))
Beispiel #3
0
def parse_table_name(tree: Node):
    if tree.get_type() == TK.TOK_DOT:
        _index = parse_value(tree.get_child(0))
        _type = parse_value(tree.get_child(1))
    elif tree.get_type() == TK.TOK_VALUE:
        _index = tree.get_value()
        _type = 'base'
    return (_index,_type)
Beispiel #4
0
def parse_value(tree: Node) -> str:
    if tree.get_type() == TK.TOK_DOT:
        retval = parse_value(tree.get_child(0))
        retval += '.'
        retval += parse_value(tree.get_child(1))
        return retval
    elif tree.get_type() == TK.TOK_VALUE:
        return tree.get_value()
    else:
        pass
Beispiel #5
0
    def __init__(self, tree: Node, root=True):

        if tree.get_type() == TK.TOK_REVERSED:
            tree = tree.get_child(0)
            self.reversed = True

        self.root = root
        self.combine = 'must'
        if tree.get_type() == TK.TOK_COMPOUND:
            self.combine = tree.get_value()
            self.lchild = QueryBody(tree.get_child(0), False)
            self.rchild = QueryBody(tree.get_child(1), False)
        else:
            self.lchild = query_expression(tree)
Beispiel #6
0
 def __init__(self, tree: Node):
     self.function_name = tree.get_value()
     self.function_parms = tree.get_children()
Beispiel #7
0
def parse_tok_value(tree: Node):
    if tree.children != None:
        if tree.get_child(0).get_type() == TK.TOK_DQ_VALUE:
            return '"' + tree.get_value() + '"'
    return tree.get_value()