I have a streaming Dataframe that I want to calculate min and avg over some columns.
Instead of getting separate resulting columns of min and avg after applying the operations, I want to merge the min and average output into a single column.
The dataframe look like this:
+-----+-----+ | 1 | 2 | +-----+-----+- |24 | 55 | +-----+-----+ |20 | 51 | +-----+-----+ I thought I'd use a Scala tuple for it, but that does not seem to work:
val res = List("1","2").map(name => (min(col(name)), avg(col(name))).as(s"result($name)")) All code used:
val res = List("1","2").map(name => (min(col(name)),avg(col(name))).as(s"result($name)")) val groupedByTimeWindowDF1 = processedDf.groupBy($"xyz", window($"timestamp", "60 seconds")) .agg(res.head, res.tail: _*) I'm expecting the output after applying the min and avg mathematical opearations to be:
+-----------+-----------+ | result(1)| result(2)| +-----------+-----------+ |20 ,22 | 51,53 | +-----------+-----------+ How I should write the expression?