Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spark window function with synthetic timestamp?

Say I have a datafile with records where each record has a timestamp, like this:

foo,bar,blaz,timestamp1
foo,flibble,baz,timestamp2
bleh,foo,gnarly,timestamp3
...

and I want to process this using Spark, in a way that requires using the window() function. Is there any way to read these records, and get each one into the DStream so that the timestamp that will be used by the window() function is provided by my code explicitly (based on parsing the timestamp field in the input records in this case)?

like image 863
mindcrime Avatar asked Apr 09 '26 09:04

mindcrime


1 Answers

No, the default Spark processing is based on the system time. And if you want to build the window using the event time. I suggest you use up "updateStateByKey" function to handle the logic inside the update function.

like image 186
Tao Li Avatar answered Apr 11 '26 23:04

Tao Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!