【问题标题】:Unable to read hive table content after writing the same through spark shell in hdp 3.0.1 using hive warehouse connector使用 hive 仓库连接器在 hdp 3.0.1 中通过 spark shell 写入相同内容后无法读取 hive 表内容
【发布时间】:2020-10-16 23:15:56
【问题描述】:

我已经使用 hive 仓库连接器在 hive 中编写了表。但是我在写完之后无法阅读相同的内容。以下是使用的命令的详细信息:

写入数据的命令:


hive.createTable("sales_22feb").ifNotExists().column("userid","string").column("ordertime","string").column("saleamount","string").column("orderid","string").create()

val df= spark.read.csv("/tmp/sales.csv")

df.write.format("com.hortonworks.spark.sql.hive.llap.HiveWarehouseConnector").option("table", "sales_22feb").mode("append").save()

 

读取数据的命令:

val hive = com.hortonworks.spark.sql.hive.llap.HiveWarehouseBuilder.session(spark).build() 

hive.setDatabase("default")

val df=hive.executeQuery("select * from sales_22feb")

df.show(5,false)
 

出现以下错误:

20/06/25 16:43:54 WARN TaskSetManager:在阶段 1.0 中丢失任务 0.0(TID 4,sandbox-hdp.hortonworks.com,执行程序 1):java.lang.RunTimeException:java.lang.NullPointerException:必须定义 hive.llap.daemon.service.hosts

但是我可以使用 hive shell 查看相同的内容。请帮我解决这个问题。

提前致谢。

【问题讨论】:

    标签: apache-spark hive apache-spark-sql hdp


    【解决方案1】:

    您需要在 spark-defaults.conf 中将“spark.hadoop.hive.llap.daemon.service.hosts”设置为 llap 守护程序的名称或使用 --conf 传递。

    例如: 如果 llap 守护进程是 @llap_LlapCluster,则需要在 spark-defaults.conf 中指定如下:

    spark.hadoop.hive.llap.daemon.service.hosts @llap_LlapCluster
    
    

    【讨论】:

      【解决方案2】:

      从 HDP 3.X 开始,通过 Hive Warehouse Connector (HWC) 框架支持读/写内部配置单元表。

      当您写入配置单元表时 Hive LLAP 服务 不是必需的。

      当您从 hive 表中读取时,需要 Hive LLAP 服务。查看以下文档以配置 spark HWC。

      https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/integrating-hive/content/hive_configure_a_spark_hive_connection.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-15
        • 2019-07-09
        • 2018-05-06
        相关资源
        最近更新 更多