I have a dataframe df1 with a column col1 that has structure :
StructField(recipientResource,ArrayType(StructType(List(StructField(resourceId,StringType,true),StructField(type,StringType,true))),true),true)
and another dataframe df2 with col1 that has structure:
StructField(recipientResource,StructType(List(StructField(resourceId,StringType,true),StructField(type,StringType,true))),true)
Inorder to union df1.union(df2), I was trying to cast the column in df2 to convert it from StructType to ArrayType(StructType), however nothing which I tried has worked out.
Can anyone suggest how to go about the same. I'm new to pyspark, any help is appreciated.
array<struct<...>>
andstruct<...>
are two completely different objects - you cannot cast one into another. You could add wrappingarray
if that's what you mean, likeselect(array(struct_column))
. – Alper t. Turker