配置单元服务器2旧客户端错误:必需字段“operationhandle”未设置

rks48beu  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(406)

我试图在cdh4.3上的配置单元server2上运行下面的配置单元节俭代码,并出现下面的错误。下面是我的代码:我可以成功地运行hivejdbc连接到同一个服务器,这只是节俭不起作用。

public static void main(String[] args) throws Exception
{
   TSocket transport = new TSocket("my.org.hiveserver2.com",10000);
   transport.setTimeout(999999999);
   TBinaryProtocol protocol = new TBinaryProtocol(transport);
   TCLIService.Client client = new TCLIService.Client(protocol);

   transport.open();

   TOpenSessionReq openReq = new TOpenSessionReq();
   TOpenSessionResp openResp = client.OpenSession(openReq);
   TSessionHandle sessHandle = openResp.getSessionHandle();
   TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, "SELECT * FROM testhivedrivertable");
   TExecuteStatementResp execResp = client.ExecuteStatement(execReq);
   TOperationHandle stmtHandle = execResp.getOperationHandle();
   TFetchResultsReq fetchReq = new TFetchResultsReq(stmtHandle, TFetchOrientation.FETCH_FIRST, 1);
   TFetchResultsResp resultsResp = client.FetchResults(fetchReq);

   TRowSet resultsSet = resultsResp.getResults();
   List<TRow> resultRows = resultsSet.getRows();
   for(TRow resultRow : resultRows){
       resultRow.toString();
   }

   TCloseOperationReq closeReq = new TCloseOperationReq();
   closeReq.setOperationHandle(stmtHandle);
   client.CloseOperation(closeReq);
   TCloseSessionReq closeConnectionReq = new TCloseSessionReq(sessHandle);
   client.CloseSession(closeConnectionReq);

   transport.close();

}

以下是错误日志:

Exception in thread "main" org.apache.thrift.protocol.TProtocolException: Required field 'operationHandle' is unset! Struct:TFetchResultsReq(operationHandle:null, orientation:FETCH_FIRST, maxRows:1)
        at org.apache.hive.service.cli.thrift.TFetchResultsReq.validate(TFetchResultsReq.java:465)
        at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args.validate(TCLIService.java:12607)
        at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args$FetchResults_argsStandardScheme.write(TCLIService.java:12664)
        at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args$FetchResults_argsStandardScheme.write(TCLIService.java:12633)
        at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args.write(TCLIService.java:12584)
        at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63)
        at org.apache.hive.service.cli.thrift.TCLIService$Client.send_FetchResults(TCLIService.java:487)
        at org.apache.hive.service.cli.thrift.TCLIService$Client.FetchResults(TCLIService.java:479)
        at HiveJDBCServer1.main(HiveJDBCServer1.java:26)
djmepvbi

djmepvbi1#

确实要将operationshandle字段设置为有效值吗?thrift eror指明了它所说的:api期望设置某个字段(在您的例子中是operationhandle),而该字段没有赋值。你的堆栈跟踪证实了这一点:
struct:tfetchresultsreq(操作员)ionhandle:null,或ientation:fetch_first, maxrows:1)

vql8enpb

vql8enpb2#

如果有人像我一样通过谷歌搜索错误消息发现了这一点:我在hiverserver2的php旧库中遇到了类似的问题。至少在我的例子中,execresp.getoperationhandle()返回null,因为生成execresp的已执行请求中存在错误。出于某种原因,这没有引发异常,在尝试获取操作句柄之前,我必须详细检查execresp,并特别检查状态。

相关问题