I have a Spark DataFrame df with five columns. I want to add another column with its values being the tuple of the first and second columns. When u
DataFrame
df
You can merge multiple dataframe columns into one using array.
// $"*" will capture all existing columns df.select($"*", array($"col1", $"col2").as("newCol"))