How to escape column names with hyphen in Spark SQL

前端 未结 3 776
暗喜
暗喜 2020-12-20 11:50

I have imported a json file in Spark and convertd it into a table as

myDF.registerTempTable(\"myDF\")

I then want to run SQL queries on th

3条回答
  •  被撕碎了的回忆
    2020-12-20 12:49

    Backticks (`) appear to work, so

    val newTable = sqlContext.sql("select `column-1` from myDF")
    

    should do the trick, at least in Spark v1.3.x.

提交回复
热议问题