I have two dataframes:
dataframe1
DATE1|
+----------+
|2017-01-08|
|2017-10-10|
|2017-05-01|
dataframe2
|NAME | SID| DATE1| DATE2|ROLL| SCHOOL|
+------+----+----------+----------+----+--------+
| Sayam|22.0| 8/1/2017| 7 1 2017|3223| BHABHA|
|ADARSH| 2.0|10-10-2017|10.03.2017| 222|SUNSHINE|
| SADIM| 1.0| 1.5.2017| 1/2/2017| 111| DAV|
Expected output
| NAME| SID| DATE1| DATE2|ROLL| SCHOOL|
+------+----+----------+----------+----+--------+
| Sayam|22.0|2017-01-08| 7 1 2017|3223| BHABHA|
|ADARSH| 2.0|2017-10-10|10.03.2017| 222|SUNSHINE|
| SADIM| 1.0|2017-05-01| 1/2/2017| 111| DAV|
I want to replace the DATE1 column in the dataframe2 with the DATE1 column of the dataframe1. I need a generic solution.
Any help will be appreciated.
I have tried withColumn method as following
dataframe2.withColumn(newColumnTransformInfo._1, dataframe1.col("DATE1").cast(DateType))
But, I'm getting an error:
org.apache.spark.sql.AnalysisException: resolved attribute(s)