从不同版本的HIVE获得的TFetchResultsResp结果之间的冲突

时间:2015-01-21 07:21:30

标签: c# hadoop hive thrift

我使用thrift生成了TCLIService的C#源,连接到Hiveserver2,当我将hiveserver2与Hive版本0.13连接时,TFetchResultsResp结果总是以列的值返回,而不是在行中返回,即行数总是为零。

当我尝试使用Hive版本0.12时,TFetchResultsResp结果总是以行而不是列的形式返回,即列数始终为零。

请告知我是否需要设置任何属性以在所有Hive版本中获取结果中的列和行。

        TSocket transport = new TSocket("localhost", 10000);
        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.SessionHandle;

        TExecuteStatementReq execReq = new TExecuteStatementReq();
        execReq.SessionHandle = sessHandle;
        execReq.Statement = "show tables";
        TExecuteStatementResp execResp = client.ExecuteStatement(execReq);
        TOperationHandle stmtHandle = execResp.OperationHandle;

        TFetchResultsReq fetchReq = new TFetchResultsReq();
        fetchReq.OperationHandle = stmtHandle;
        fetchReq.Orientation = TFetchOrientation.FETCH_FIRST;
        fetchReq.MaxRows = 99999999;
        TFetchResultsResp resultsResp = client.FetchResults(fetchReq);

        TRowSet resultsSet = resultsResp.Results;
        //In hive version 0.13, rows count zero
        List<TRow> resultRows = resultsSet.Rows;
        //In Hive version 0.12, columns count zero
        List<TColumn> resultColumn = resultsSet.Columns;


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

        transport.Close();

1 个答案:

答案 0 :(得分:0)

原因是之前的序列化设计(行专业)效率非常低,导致了大量不必要的网络流量。目前的设计(专栏专业)解决了其中一些问题。

https://issues.apache.org/jira/browse/HIVE-3746