在Spark上通过JDBC从远程配置单元读取数据返回空结果 [英] Read data from remote hive on spark over JDBC returns empty result
问题描述
我需要在spark上对远程hive服务器执行hive查询,但由于某些原因,我只收到列名(没有数据)。
表中的数据,我通过HUE和java jdbc连接进行了检查。
这是我的代码示例:
val test = spark.read
.option(url,jdbc:hive2://remote.hive.server:10000 / work_base)
.option(user,user)
.option(password,password)
.option(dbtable,some_table_with_data)
.option (driver,org.apache.hive.jdbc.HiveDriver)
.format(jdbc)
.load()
test.show()
输出:
+ ------- +
| dst.col |
+ ------- +
+ ------- +
我知道这个表上的数据可用。
Scala版本:2.11
Spark版本:2.1.0,我也试过2.1.1
Hive版本:CDH 5.7 Hive 1.1.1,在HDP上我有同样的故事
Hive JDBC版本:1.1.1我也尝试过更新版本
但是这个问题也可以在更高版本的Hive上使用。
你能帮我解决这个问题,因为我在邮件组的答案和StackOverflow中找不到任何东西。
也许你知道我怎么可以从spark执行hive查询到远程服务器?
您应该将此添加到您的选项:
.option(fetchsize,10)
pre>
I need to execute hive queries on remote hive server from spark, but for some reasons i receive only column names(without data). Data available in table, i checked it via HUE and java jdbc connection.
Here is my code example:
val test = spark.read .option("url", "jdbc:hive2://remote.hive.server:10000/work_base") .option("user", "user") .option("password", "password") .option("dbtable", "some_table_with_data") .option("driver", "org.apache.hive.jdbc.HiveDriver") .format("jdbc") .load() test.show()
Output:
+-------+ |dst.col| +-------+ +-------+
I know that data vailable on this table.
Scala version: 2.11 Spark version: 2.1.0, i also tried 2.1.1 Hive version: CDH 5.7 Hive 1.1.1, on HDP i have same story Hive JDBC version: 1.1.1 i also tried later versions
But this problem available on Hive with later versions, too. Could you help me with this issue, because i didn't find anything in mail group answers and StackOverflow. Maybe you know how i can execute hive queries from spark to remote servers?
解决方案You should add this into your options:
.option("fetchsize", "10")
这篇关于在Spark上通过JDBC从远程配置单元读取数据返回空结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!