def analy_query_tree(self, query_tree, cluster_name):
        try:
            query_tree_dict = json.loads(query_tree)
        except JSONDecodeError:
            query_tree_dict = json.loads(repair_json_str(query_tree))

        select_list = query_tree_dict.get('select_list')
        table_ref = query_tree_dict.get('table_ref')

        # 获取全部脱敏字段信息，减少循环查询，提升效率
        DataMaskingColumnsOb = DataMaskingColumns.objects.all()

        # 判断语句涉及的表是否存在脱敏字段配置
        is_exist = False
        for table in table_ref:
            if DataMaskingColumnsOb.filter(cluster_name=cluster_name,
                                           table_schema=table['db'],
                                           table_name=table['table'],
                                           active=1).exists():
                is_exist = True
        # 不存在脱敏字段则直接跳过规则解析
        if is_exist:
            # 遍历select_list
            columns = []
            hit_columns = []  # 命中列
            table_hit_columns = []  # 涉及表命中的列，仅select *需要

            # 判断是否存在不支持脱敏的语法
            for select_item in select_list:
                if select_item['type'] not in ('FIELD_ITEM', 'aggregate'):
                    raise Exception('不支持该查询语句脱敏！')
                if select_item['type'] == 'aggregate':
                    if select_item['aggregate'].get('type') not in ('FIELD_ITEM', 'INT_ITEM'):
                        raise Exception('不支持该查询语句脱敏！')

            # 获取select信息的规则，仅处理type为FIELD_ITEM和aggregate类型的select信息，如[*],[*,column_a],[column_a,*],[column_a,a.*,column_b],[a.*,column_a,b.*],
            select_index = [
                select_item['field'] if select_item['type'] == 'FIELD_ITEM' else select_item['aggregate'].get('field')
                for
                select_item in select_list if select_item['type'] in ('FIELD_ITEM', 'aggregate')]

            # 处理select_list，为统一的{'type': 'FIELD_ITEM', 'db': 'archer_master', 'table': 'sql_users', 'field': 'email'}格式
            select_list = [select_item if select_item['type'] == 'FIELD_ITEM' else select_item['aggregate'] for
                           select_item in select_list if select_item['type'] in ('FIELD_ITEM', 'aggregate')]

            if select_index:
                # 如果发现存在field='*',则遍历所有表,找出所有的命中字段
                if '*' in select_index:
                    # 涉及表命中的列
                    for table in table_ref:
                        hit_columns_info = self.hit_table(DataMaskingColumnsOb, cluster_name, table['db'],
                                                          table['table'])
                        table_hit_columns.extend(hit_columns_info)
                    # 几种不同查询格式
                    # [*]
                    if re.match(r"^(\*,?)+$", ','.join(select_index)):
                        hit_columns = []
                    # [*,column_a]
                    elif re.match(r"^(\*,)+(\w,?)+$", ','.join(select_index)):
                        # 找出field不为* 的列信息, 循环判断列是否命中脱敏规则，并增加规则类型和index，index采取后切片
                        for index, item in enumerate(select_list):
                            item['index'] = index - len(select_list)
                            if item.get('field') != '*':
                                columns.append(item)

                    # [column_a, *]
                    elif re.match(r"^(\w,?)+(\*,?)+$", ','.join(select_index)):
                        # 找出field不为* 的列信息, 循环判断列是否命中脱敏规则，并增加规则类型和index,index采取前切片
                        for index, item in enumerate(select_list):
                            item['index'] = index
                            if item.get('field') != '*':
                                columns.append(item)

                    # [column_a,a.*,column_b]
                    elif re.match(r"^(\w,?)+(\*,?)+(\w,?)+$", ','.join(select_index)):
                        # 找出field不为* 的列信息, 循环判断列是否命中脱敏规则，并增加规则类型和index,*前面的字段index采取前切片,*后面的字段采取后切片
                        for index, item in enumerate(select_list):
                            item['index'] = index
                            if item.get('field') == '*':
                                first_idx = index
                                break

                        select_list.reverse()
                        for index, item in enumerate(select_list):
                            item['index'] = index
                            if item.get('field') == '*':
                                last_idx = len(select_list) - index - 1
                                break

                        select_list.reverse()
                        for index, item in enumerate(select_list):
                            if item.get('field') != '*' and index < first_idx:
                                item['index'] = index

                            if item.get('field') != '*' and index > last_idx:
                                item['index'] = index - len(select_list)
                            columns.append(item)

                    # [a.*, column_a, b.*]
                    else:
                        raise Exception('不支持select信息为[a.*, column_a, b.*]格式的查询脱敏！')

                # 没有*的查询，直接遍历查询命中字段，query_tree的列index就是查询语句列的index
                else:
                    for index, item in enumerate(select_list):
                        item['index'] = index
                        if item.get('field') != '*':
                            columns.append(item)

            # 格式化命中的列信息
            for column in columns:
                hit_info = self.hit_column(DataMaskingColumnsOb, cluster_name, column.get('db'), column.get('table'),
                                           column.get('field'))
                if hit_info['is_hit']:
                    hit_info['index'] = column['index']
                    hit_columns.append(hit_info)
        else:
            table_hit_columns = None
            hit_columns = None
        return table_hit_columns, hit_columns