How can i change the string type to datetime type on my elements of nested array (transaction_date)? Here are the spark dataframe that i have :
root
|-- id
|-- data: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- transaction: array (nullable = true)
| | | |-- element: struct (containsNull = true)
| | | | |-- timestamp: string (nullable = true)
| | | | |-- transaction_date: string (nullable = true)
I had trying using this code, but it return error:
df = df.withColumn("transaction_date", df.data.transaction.transaction_date.cast(TimestampType()))