Suppose I have a Spark Scala DataFrame object like:
+----------------+
|col1 |col2 |
+----------------+
|1 |2 |
|3 |4 |
+----------------+
And I want a DataFrame like:
+--------------------+
|col1 |col2 |col3 |
+--------------------+
|1 |2 |3 |
|3 |4 |7 |
+--------------------+
Which adds col1 and col2 to col3, could anyone please tell me how to do that? WithColumn takes only one column as parameter whereas I need to take two columns.
withColumnis lazy and will be optimized at runtime, I'm fairly sure you can call it twice for the two columns without any problem.