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
Valued Contributor
Valued Contributor
Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!