I am trying to fill a new column with Y or N. To do that I check two columns and if one of this has a True value, I put Y in the new column else put a N.
For example, I have this dataframe:
+--------------+----------+----------+------------------+--------+--------+-------------------+
|Date |Col1 | Col2 |ChangeinCol1_Col2 | Col3 | Col4 | ChangeinCol3_Col4 |
+--------------+----------+----------+------------------+--------+--------+-------------------+
|2020-12-14 |True | False | Y | False | False | N |
|2020-12-14 |False | False | Y | False | False | N |
If there is a True in Col1 or Col2, the column ChangeinCol1_Col2 will be Y, same for ChangeinCol3_Col4 but in this case there are N because there are not changes in Col3 and Col4.
How could I do this with Apache Spark in Scala? I am trying it with df.withColumn to create the new column but don't know how to check the value in the cols.