【问题标题】:How to Read Hive Table in Spark without header如何在没有标题的情况下在 Spark 中读取 Hive 表
【发布时间】:2020-07-05 23:55:29
【问题描述】:
我正在尝试在 pyspark 中读取一个配置单元表,但我也得到了我不想要的标题。
文件.csv
Id,Name
1,A
2,B
3,C
4,D
蜂巢表
我使用tblproperties("skip.header.line.count"="1") 构建 hive 表,并且在 Hive 中我正确获取数据,因此 Hive 没有问题。
我在 pyspark 中阅读此表时遇到问题。
【问题讨论】:
标签:
apache-spark
pyspark
hive
header
【解决方案1】:
有Spark-11374jira 报告了此问题,并以won't fix 关闭。
可能的方法是:
1.You can directly read the HDFS file:
spark.read.option("header","true").option("delimiter",",").csv("<hdfs_path>").show()
2.using hive query:
spark.sql("select * from <table_name> where <col_name1> != 'id'").show()