【发布时间】:2018-05-16 07:46:58
【问题描述】:
假设我有一个这样的 CSV 文件:
"Col1Name", "Col2Name"
"a", "b"
"c", "d"
假设我在 Athena 中发出以下 CREATE EXTERNAL TABLE 命令:
CREATE EXTERNAL TABLE test.sometable (
col1name string,
col2name string
)
row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
with serdeproperties (
'separatorChar' = ',',
'quoteChar' = '\"',
'escapeChar' = '\\'
)
stored as textfile
location 's3://somebucket/some/path/'
tblproperties("skip.header.line.count"="1")
然后我发出以下 SELECT:
SELECT * FROM test.sometable
我希望得到以下结果:
+----------+----------+
| col1name| col2name|
+----------+----------+
| a| b|
| c| d|
+----------+----------+
...果然,这正是我得到的。
在使用 Spark 中的 AWS Glue 元数据目录的 EMR 集群上,我在 pyspark REPL 中发出以下命令:
a = spark.sql("select * from test.sometable")
a.show()
我希望收到相同的输出,但相反,我得到了:
+----------+----------+
| col1name| col2name|
+----------+----------+
| col1name| col2name|
| a| b|
| c| d|
+----------+----------+
显然,Athena 尊重“skip.header.line.count”tblproperty,但 PySpark 似乎忽略了它。
如何让 PySpark 像 Athena 一样忽略此标题行?
【问题讨论】:
-
这个问题能给你答案吗? stackoverflow.com/questions/49866197/…
标签: pyspark amazon-emr pyspark-sql aws-glue