Group by column “grp” and compress DataFrame - (take last not null value for each column ordering by column “ord”)
问题 Assuming I have the following DataFrame: +---+--------+---+----+----+ |grp|null_col|ord|col1|col2| +---+--------+---+----+----+ | 1| null| 3|null| 11| | 2| null| 2| xxx| 22| | 1| null| 1| yyy|null| | 2| null| 7|null| 33| | 1| null| 12|null|null| | 2| null| 19|null| 77| | 1| null| 10| s13|null| | 2| null| 11| a23|null| +---+--------+---+----+----+ here is the same sample DF with comments, sorted by grp and ord : scala> df.orderBy("grp", "ord").show +---+--------+---+----+----+ |grp|null_col