Spark SQL ODBC连接未连接

时间:2015-05-14 07:27:05

标签: odbc apache-spark thrift

我使用以下命令构建了火花源

mvn -Pyarn -Phadoop-2.5 -Dhadoop.version=2.5.2 -Phive -Phive-1.1.0 -Phive-thriftserver -DskipTests clean package

我使用以下命令启动了thrift服务器

spark-submit --class org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 --master local[*]   file:///c:/spark-1.3.1/sql/hive-thriftserver/target/spark-hive-thriftserver_2.10-1.3.1.jar

使用以下命令

在beeline中连接thriftserver
Jdbc:hive2://localhost:10000

使用以下查询

创建名为people的表
Create table people(Name String);
Load data local inpath ‘C:\spark-1.3.1\examples\src\main\resources\people.txt’ overwrite into table people;

如何使用odbc连接或thrift库从C#应用程序中读取此表?

我使用以下代码片段来使用thrift和Thrift dll生成的C#代码来读取表格

Console.WriteLine("Thrift hive server for Spark SQL Connection....");

TSocket hiveSocket = new TSocket("localhost", 10000);
TBinaryProtocol protocol =new TBinaryProtocol(hiveSocket);
ThriftHive.Client client = new ThriftHive.Client(protocol);

if (!hiveSocket.IsOpen)
{
    hiveSocket.Open();
}
Console.WriteLine("Thrift server connected");

client.execute("select * from people1");

但我无法执行查询。

1 个答案:

答案 0 :(得分:0)

它没有抛出任何错误或异常,因为可能没有错误并且处理有效。您只需要使用client.fetchAll()实际检索结果。