Mapping json to case class with Spark (spaces in the field name)

∥☆過路亽.° 提交于 2019-12-01 11:28:48

A workaround is to create a column name without space (give underscore) & rename the DF column to match the case class column name.

case class MyType(Field_Name: String)

dataframe.withColumnRenamed("Field Name", "Field_Name").as[MyType]

FYI I have created a Spark bug about this issue and they are fixing it https://issues.apache.org/jira/browse/SPARK-22442

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!