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

标签 c# hadoop hive 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();

最佳答案

原因是以前的序列化设计(行主要)效率很低,并且导致了许多不必要的网络流量。当前的设计(专业专栏)解决了其中一些问题。

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

关于c# - 从不同版本的HIVE获得的TFetchResultsResp结果之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28061614/

相关文章:

c# - 我们可以在javascript和除Literal之外的其他部分使用Resource Expressions吗?

json - 如何从json数据创建hive表

apache-spark - 为什么在完成作业和关闭 Spark 之间会发生磁盘繁忙尖峰?

powershell - 如何使用Powershell使用Hive Metastore创建Azure HDInsight群集?

hadoop - hadoop跨数据库查找表

c# - Oracle DataAccess 相关 : "The invoked member is not supported in a dynamic assembly."

c# - Azure表存储查询分区键

c# - ajax beginForm 忽略指定按钮

hadoop - 如何在Hive中使用2 for循环

hadoop - 我应该如何将我的事件流保存到冷存储?