0 Replies Latest reply on Mar 27, 2012 5:39 PM by markaddleman

    Windowing & Continuous Executions

    markaddleman

      I'd like to propose a mechanism to window continuous executions to allow for a stream of aggregates without introducing new SQL keywords.  For example, a common use case is to get the count of events over a stream of 10 minute time blocks.

       

      Suppose Teiid introduced a windowClosed() method on ExecutionContext. Any translator participating in a place could call windowClosed() to indicate that the engine should produce a result over the accumualted results as if the execution were closed but, windowClosed would still allow the execution to continue.

       

      I imagine that I could write the following query:

      SELECT window.timestamp, count(t.event)

      FROM (call window.produce_timestamps(60, 'SECONDS')) as window, t

      The implementation of "produce_time_blocks" stored procedure is an implementation of ProcedureExecution and ReusableExecution which would operate asynchronously.  Every 60 seconds, it would

      1. Call dataAvailable()
      2. Return a single column result set of the current timestamp
      3. Call windowClosed()

      The engine would then have enough information to produce a result set from the query.  It would then reset all ReusableExecutions and continue processing the plan.

       

      I believe this approach would allow for GROUP BY and ORDER BY operations within execution windows, as well.

       

      Thoughts?