1 ) A method executed by a database system, comprising: receiving, at a query engine in the database system, a continuous stream of data in data chunks; applying a Structured Query Language (SQL) query with User Defined Functions (UDFs) to the data chunks of the continuous stream of data; and processing, by the database system, the data chunks on a chunk-by-chunk basis with a query rewind mechanism to sustain the SQL query as a single long-standing query that allows the UDFs and a state of the SQL query to be maintained.