Exploding nested Struct in Spark dataframe

后端 未结 3 1801
时光取名叫无心
时光取名叫无心 2020-12-01 14:26

I\'m working through a Databricks example. The schema for the dataframe looks like:

> parquetDF.printSchema
root
|-- department: struct (nullable = true)
|         


        
3条回答
  •  醉酒成梦
    2020-12-01 14:33

    This seems to work (though maybe not the most elegant solution).

    var explodeDF2 = explodeDF.withColumn("id", explodeDF("department.id"))
    explodeDF2 = explodeDF2.withColumn("name", explodeDF2("department.name"))
    

提交回复
热议问题