cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to dynamically explode array type column in pyspark or scala

SatheeshSathees
New Contributor

HI,

i have a parquet file with complex column types with nested structs and arrays.

I am using the scrpit from below link to flatten my parquet file.

https://docs.microsoft.com/en-us/azure/synapse-analytics/how-to-analyze-complex-schema

I am able to flatten schema using script in STEP 1 and STEP 2 successfully. But in the above link, for STEP 3 the script uses hardcoded column names to flatten arrays. But in my case i have multiple columns of array type that need to be transformed so i cant use this method.

Is there any way to dynamically transform all the array type columns without hardcoding because in future the columns may change in my case. Something like check if a column is of array type and explode it dynamically and repeat for all columns of arrays.

Please advise

1 REPLY 1

shyam_9
Databricks Employee
Databricks Employee

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group