我使用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)
得到以下错误:
25-06-20 16:43:54 警告 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 看到相同的内容。请帮帮我。
提前谢谢。
您需要将"spark.hadoop.hive.llap.daemon.service.hosts"设置为spark-defaults.conf中的llap守护进程的名称,或者使用--conf传递。
例如: 如果 llap 守护进程@llap_LlapCluster,则需要在 spark-defaults.conf 中指定如下:
spark.hadoop.hive.llap.daemon.service.hosts @llap_LlapCluster
从 HDP 3.X 开始,通过 Hive仓库连接器 (HWC(框架支持读取/写入内部 Hive 表。
写入配置单元表时,不需要Hive LLAP 服务。
当您从配置单元表中读取时,需要Hive LLAP 服务。查看以下文档以配置火花 HWC。
https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/integrating-hive/content/hive_configure_a_spark_hive_connection.html