Caroline McKee
12/12/2023, 6:20 PMvalue[0] in both is the UTC time string to the millisecond associated with the event). So basically I end up with the timestamp being a long int corresponding to the unix time in milliseconds:
class BaseTimestampAssigner(TimestampAssigner):
def extract_timestamp(self, value, record_timestamp):
time = int(dateparser.parse(value[0]).timestamp() * 1000)
return time
After reading in data, assigning timestamp (and a monotonous_timestamp watermark strategy) for both. I stream to table and run an interval join:
pl_dist_table = t_env.from_data_stream(processed_pl_dist_stream, col("frame_time"), col("pl_dist"), col("def_id"), col("off_id"), col("rowtime1").rowtime)
ba_dist_table = t_env.from_data_stream(processed_ba_dist_stream, col("frame_time_ba"), col("ba_dist"), col("player_id"), col("rowtime2").rowtime)
res_table = (pl_dist_table.join(ba_dist_table)
.where((col("off_id") == col("player_id")) & (col("rowtime1") > col("rowtime2") - lit(100).milli) & (col("rowtime1") < col("rowtime2") + lit(100).milli))
.select(col("frame_time"), col("pl_dist"), col("def_id"), col("off_id"), col("ba_dist")))
What I'm curious about is how Flink knows that the rowtime/timestamp is in milliseconds during the interval join, given that the timestamp assigner ultimately just assigns a long int to each event. Is there underlying logic that says if the timestamp is a long int, assume it refers to unix time milliseconds?
Additionally, would I be able to replace the two range predicates with a single equality? ie. col("rowtime1) = col("rowtime2") if I only need to join the two streams when the timestamps are exactly equal, ie. effectively a join on time and id. Would this be as memory efficient as using the two range predicates?