Exemplo n.º 1
0
    def __init__(self, tree: Node):

        #do query
        for element in tree.get_children():
            if element.get_type() == TK.TOK_FROM:
                (self._index,
                 self._type) = parse_tok_table_name(element.get_child(0))
                if element.get_children_count() == 2:
                    self.route = parse_value(element.get_child(1))

            if element.get_type() == TK.TOK_SELECT:
                self.selexpr = parse_tok_selexpr(element)

            if element.get_type() == TK.TOK_WHERE:
                self.query_body = QueryBody(element.get_child(0))

            if element.get_type() == TK.TOK_LIMIT:
                (self._from, self._size) = parse_tok_limit(element)

            if element.get_type() == TK.TOK_ORDERBY:
                self.sorts = parse_tok_sorts(element)

        #do aggregations
        for element in tree.get_children():
            if element.get_type() == TK.TOK_GROUPBY:
                agg_size = -1
                if hasattr(self, '_size'):
                    agg_size = self._size
                self.groupby = AggBuckets(element, agg_size)
Exemplo n.º 2
0
 def __init__(self, tree: Node):
     for element in tree.get_children():
         if element.get_type() == TK.TOK_TABLE_NAME:
             (self._index, self._type) = parse_tok_table_name(element)
         if element.get_type() == TK.TOK_SET_COLUMNS_CLAUSE:
             self.update_sets = parse_update_sets(element)
         if element.get_type() == TK.TOK_WHERE:
             self.conditions = parse_conditions(element)
Exemplo n.º 3
0
 def __init__(self, tree: Node):
     self.insert_columns = []
     self.bulk_rows = []
     for element in tree.get_children():
         if element.get_type() == TK.TOK_TABLE_NAME:
             (self._index, self._type) = parse_tok_table_name(element)
         elif element.get_type() == TK.TOK_INSERT_COLUMNS:
             self.insert_columns = parse_insert_columns(element)
         elif element.get_type() == TK.TOK_INSERT_ROWS:
             self.bulk_rows = parse_bulk_rows(element)
Exemplo n.º 4
0
 def __init__(self, tree: Node):
     self.insert_columns = []
     self.insert_row = []
     self.metas = {}
     for element in tree.get_children():
         if element.get_type() == TK.TOK_TABLE_NAME:
             (self._index, self._type) = parse_tok_table_name(element)
         elif element.get_type() == TK.TOK_INSERT_COLUMNS:
             self.insert_columns = parse_insert_columns(element)
         elif element.get_type() == TK.TOK_INSERT_ROW:
             self.insert_row = parse_insert_row(element)
     for i in range(0, len(self.insert_columns)):
         if self.insert_columns[i] in [
                 '_id', '_parent', '_routing', '_type'
         ]:
             self.metas[self.insert_columns[i][1:]] = self.insert_row[i]
Exemplo n.º 5
0
 def __init__(self, tree: Node):
     for element in tree.get_children():
         if element.get_type() == TK.TOK_TABLE_NAME:
             (self._index, self._type) = parse_tok_table_name(element)
         if element.get_type() == TK.TOK_WHERE:
             self.conditions = QueryBody(element.get_child(0))
Exemplo n.º 6
0
 def __init__(self, tree: Node):
     for element in tree.get_children():
         if element.get_type() == TK.TOK_TABLE_NAME:
             (self._index, self._type) = parse_tok_table_name(element)