>
> 1)  Is a struct in Spark like a struct in C++?
>

Kinda.  Its an ordered collection of data with known names/types.


> 2)  What is an alias in this context?
>

it is assigning a name to the column.  similar to doing AS in sql.


> 3)  How does this code even work?
>

Ordering for a struct goes in order of the fields.  So the max struct is
the one with the highest TotalValue (and then the highest category if there
are multiple entries with the same hour and total value).


> 4)  Is it faster doing it this way than doing a join or window function in
> Spark SQL?
>

Way faster.  This is a very efficient way to calculate argmax.

Reply via email to