I've created a dataframe with info about sales. Now I want to add a column (metric1
) with booleans to the dataframe which values will depend on the sl.review
field: if sl.review
contains an empty string, then metric1
will be false and true
otherwise if there is a review in sl.review
.
val salesDf: DataFrame = salesRawDf.select($"stores", explode($"sales").as("sl"))
.select($"stores.id", $"stores.name", $"sl.id", $"sl.current_sales", $"sl.review")
How is it possible to achieve with DataFrame? I've read this related question but still can't figure out how to implement this in my case.