如何在SparkContext中处理带有SQL请求的破折号

时间:2017-01-03 08:15:44

标签: sql apache-spark

我在spark上下文中使用此SQL请求:

SELECT Max(F-Measure) FROM fMeasure_table

我得到了例外: enter image description here

1 个答案:

答案 0 :(得分:0)

要在Apache Spark中选择带有连字符-的列,请使用以下语法:

对于Apache Spark 1.x或更低版本:

sqlContext.sql("select max(`F-Measure`) from fMeasure_table")

对于Apache Spark 2.x或更高版本:

spark.sql("select max(`F-Measure`) from fMeasure_table")

以下是类似问题的链接:How to escape column names with hyphen in Spark SQL