1

CDH 4.3 のハイブ server2 で以下のハイブ thrift コードを実行しようとすると、以下のエラーが発生します。これが私のコードです:同じサーバーへのハイブjdbc接続を正常に実行できますが、機能していないのは単なる倹約です。

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)
4

2 に答える 2

0

operationsHandle フィールドを有効な値に設定してよろしいですか? Thrift エラーは、それが何を言っているのかを示しています: API は、値が割り当てられていない特定のフィールド (あなたの場合は operationHandle) が設定されることを期待しています。そして、スタックトレースはこれを確認します:

Struct:TFetchResultsReq( operationHandle:null , orientation:FETCH_FIRST, maxRows:1)

于 2013-09-09T20:02:15.507 に答える