Exploding nested Struct in Spark dataframe

后端 未结 3 1799
时光取名叫无心
时光取名叫无心 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:28

    In my opinion the most elegant solution is to star expand a Struct using a select operator as shown below:

    var explodedDf2 = explodedDf.select("department.*","*")
    

    https://docs.databricks.com/spark/latest/spark-sql/complex-types.html

提交回复
热议问题