【发布时间】:2018-05-15 19:09:53
【问题描述】:
我正在拨打以下电话:
propertiesDF.select(
col("timestamp"), col("coordinates")(0) as "lon",
col("coordinates")(1) as "lat",
col("properties.tide (above mllw)") as "tideAboveMllw",
col("properties.wind speed") as "windSpeed")
这给了我以下错误:
org.apache.spark.sql.AnalysisException: No such struct field 潮 (高于 mllw)在气温、大气压力、露点、 主波周期、平均波向、名称、程序名称、 有效波高、潮汐(高于 mllw):、能见度、水 温度、风向、风速;
现在肯定有这样一个struct字段。 (错误信息本身就是这么说的。)
这是架构:
root
|-- timestamp: long (nullable = true)
|-- coordinates: array (nullable = true)
| |-- element: double (containsNull = true)
|-- properties: struct (nullable = true)
| |-- air temperature: double (nullable = true)
| |-- atmospheric pressure: double (nullable = true)
| |-- dew point: double (nullable = true)
.
.
.
| |-- tide (above mllw):: string (nullable = true)
.
.
.
输入被读取为 JSON,如下所示:
val df = sqlContext.read.json(dirName)
如何处理列名中的括号?
【问题讨论】:
标签: scala apache-spark apache-spark-sql