hive-cdh5.7以后版本,程序使用hive接口进行查询,如何获取查询日志?

五哥 五哥 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
hive CHD 5.7版本前使用:
public String getQueryLog(TOperationHandle tOperationHandle) throws Exception {
//TCLIService.Client client;
if(tOperationHandle!=null){
TGetLogReq tGetLogReq = new TGetLogReq(tOperationHandle);
TGetLogResp logResp = client.GetLog(tGetLogReq);
log = logResp.getLog();
}

return log;
}
使用hive-service-0.12.0-cdh5.01.jar中的类
但是CDH5.7后,hive-service中的TCLIService.Client 中不在提供GetLog方法了,不知道有什么办法可以获取吗 ?
我查看了hive-exec-1.1.0-cdh5.12.0-core.jar中,org.apache.hive.service.cli.thrift;-ThriftCLIService
/**
*
* @param client
* 连接thriftserver的客户端
* @param operationHandle
* 当前操作对应句柄
* @param Orientation
* 获取结果的起始位置 FetchOrientation.First 从结果第一行开始取2
* @param fetchType
* 获取结果的类型 FetchType.LOG 获取此操作对应日志
* @param maxRows
* 此次获取的最大行数
* @return
*/
public static TRowSet fetchResult(TCLIService.Client client, TOperationHandle operationHandle,
FetchOrientation Orientation, FetchType fetchType, long maxRows) {

TFetchResultsReq fetchReq = new TFetchResultsReq();
fetchReq.setFetchType(fetchType.toTFetchType());
fetchReq.setMaxRows(maxRows);
fetchReq.setOperationHandle(operationHandle);
fetchReq.setOrientation(Orientation.toTFetchOrientation());
TRowSet rowSetLog = null;
try {
rowSetLog = client.FetchResults(fetchReq).getResults();
} catch (TException e) {
log.info("Exception:" + e.getStackTrace());
e.printStackTrace();
}
return rowSetLog;
}

好像可以,不知道有没有哪位大神,有弄过过的,分享一下,谢谢
...全文
评论 6
收藏 已收藏
分享
返回顶部
五哥
Hadoop生态社区 20,842 成员 4,695 内容