Showing posts with label input to function explode should be array or map type. Show all posts
Showing posts with label input to function explode should be array or map type. Show all posts

Thursday, July 15, 2021

org.apache.spark.sql.AnalysisException: cannot resolve 'explode(`mycol`)' due to data type mismatch: input to function explode should be array or map type, not struct line 1 pos 0;

Hello,

If you exploding and got above error then it means you dont need to explode it as it is not type array or map.

You can simply access values as:

df_expanded = df.withColumn("prop1", expr("mycol.prop1"))

HTH