def get_tb(self, tb_id, cols=(), user_id=None, groups=[]): """ 获取表、分配表的基本信息,返回字段列表等信息,默认返回表的所有信息 如果需要获取表的使用者创建的计算字段信息,必须传user_id :param tb_id: :param cols: :param user_id: :return: """ # 如果是sh_开头的tb_id一定是分享表id,分享表在使用上和普通的表是一样的,只是多出了过滤条件信息 # todo 需要对删除虚拟列的Aggregator if tb_id.find('sh_') == 0: sh_id = tb_id share_model = Share() share_info = share_model.get_one(sh_id) if not share_info: self.logger.warn('分享表不存在:' + sh_id) return None tb_id = share_info[Share.TB_ID] tb_info = self.get_tb_info(tb_id, user_id, cols, groups=groups) if not tb_info: self.logger.warn('分享表对应的数据表不存在:sh_id:%s, tb_id:%s' % (sh_id, tb_id)) return None tb_info[Share.ROW_FILTER] = share_info[Share.ROW_FILTER] tb_info[Share.IS_FIXED] = share_info[Share.IS_FIXED] # 使用share的version替换tb的version,因为share的过滤条件有可能有修改,需要单独记录版本号 tb_info[TB.VERSION] = share_info[Share.VERSION] tb_info[TB.DATA_COUNT] = share_info[Share.DATA_COUNT] return tb_info else: tb_info = self.get_tb_info(tb_id, user_id, cols) if not tb_info: return None # fields = tb_info[TB.FIELDS] # self.change_aggregator(fields) return tb_info