Fares hussein Ответов: 0

Как объединить два искровых ряда


Hi i have a DataSet of Track.class i want to merge all tracks that are within same interval of time for example 5 min .i.e any tracks start after a track that ends within 5 min before will be the same track.its look like fusion task.

my input :

+----------+---------------------------------------------+
|  trackId |  start_time    |  end_time                  |
+-----+--------------------------------------------------+
|  1       | 12:00:00       |   12:04:00                 |
+----------+---------------------------------------------+
|  2       | 12:05:00       |   12:08:00                 |  
+----------+---------------------------------------------+
|  3       | 12:20:00       |   12:22:00                 | 
+----------+---------------------------------------------+
output :(trackId : 1,2 are been merged since diff of start and end of each one is within 5 min)

+----------+----------------+----------------------------+
|  trackId |  start_time    |  end_time                  |
+-----+--------------------------------------------------+
|  1       | 12:00:00       |  12:08:00                  |
+----------+---------------------------------------------+
|  3       | 12:20:00       |   12:22:00                 |
+----------+----------------+----------------------------+
so how i can make do that ?


Что я уже пробовал:

df.groupBy(window(df.col("time"),"50 seconds").agg(first("id").as("id"))

		    
                    

0 Ответов