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
More Related Contents:
- Flattening Rows in Spark
- How to query JSON data column using Spark DataFrames?
- Encoder error while trying to map dataframe row to updated row
- How do I detect if a Spark DataFrame has a column
- Spark Scala: How to convert Dataframe[vector] to DataFrame[f1:Double, …, fn: Double)]
- How to define schema for custom type in Spark SQL?
- How to avoid duplicate columns after join?
- How can I change column types in Spark SQL’s DataFrame?
- Spark unionAll multiple dataframes
- How can I pass extra parameters to UDFs in Spark SQL?
- How to split a dataframe into dataframes with same column values?
- Provide schema while reading csv file as a dataframe
- How to zip two (or more) DataFrame in Spark
- How to flatmap a nested Dataframe in Spark
- How to define a custom aggregation function to sum a column of Vectors?
- Joining Spark dataframes on the key
- Spark DataFrame: does groupBy after orderBy maintain that order?
- Better way to convert a string field into timestamp in Spark
- Spark UDAF with ArrayType as bufferSchema performance issues
- Apache Spark how to append new column from list/array to Spark dataframe
- How to write unit tests in Spark 2.0+?
- how to filter out a null value from spark dataframe
- What are the various join types in Spark?
- Provide schema while reading csv file as a dataframe in Scala Spark
- Replace missing values with mean – Spark Dataframe
- Apache Spark, add an “CASE WHEN … ELSE …” calculated column to an existing DataFrame
- How to calculate the size of dataframe in bytes in Spark?
- Spark-Monotonically increasing id not working as expected in dataframe?
- Calculate Cosine Similarity Spark Dataframe
- Difference between two rows in Spark dataframe