Exploding nested Struct in Spark dataframe

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

    You could use something like that:

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

    which you helped me into and these questions:

    • Flattening Rows in Spark
    • Spark 1.4.1 DataFrame explode list of JSON objects

提交回复
热议问题