Query deadlines do not play well with operators such as GROUP_BY or ORDER_BY which must buffer their outputs. Query deadlines currently interrupt the query, which terminates query processing abruptly. However, operators such as GROUP_BY or ORDER_BY buffer their outputs and may not have written any data when the query deadline elapses.
One way to handle this is to use a subquery with a deadline to materialize the solutions which are then fed into the parent query where ORDER_BY or GROUP_BY solution modifiers are applied. In addition, the query deadline would have to cause "normal" termination, rather than throwing out a TimeoutException, since exceptions are propagated to the parent query.
Currently, the deadline is tested each time an operator evaluation task starts or halts. If we introduce long-running tasks, then it might also be worthwhile to add a ScheduledTask to terminate the query after the deadline has expired.