GitHub user lw-lin opened a pull request:
https://github.com/apache/spark/pull/12725
[SPARK-14942][SQL][Streaming] First construct a batch then run the batch
for continuous queries
## Problem
Currently in `StreamExecution`, we first run the batch, then construct the
next:
```scala
if (dataAvailable) runBatch()
constructNextBatch()
```
This is good if we run batches ASAP, where data would get processed in the
**very next batch**:

However, if we run batches at trigger like `ProcessTime("1 minute")`, data
- such as _y_ below - may not get processed in the very next batch i.e. _batch
1_, but in _batch 2_:

## What changes were proposed in this pull request?
This patch reverse the order of `constructNextBatch()` and `runBatch()`.
After this patch, data would get processed in the **very next batch**, i.e.
_batch 1_:

In addition, this patch alters when we do `currentBatchId += 1`: let's do
that when the processing of the current batch of data is complete, so we won't
bother passing `currentBatchId + 1` or `currentBatchId - 1` to states or sinks.
## How was this patch tested?
This should be covered by existing test suits including stress tests.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/lw-lin/spark construct-before-run-3
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12725.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #12725
----
commit 8c8d73a85550349faafef1cbde1c7094d384809e
Author: Liwei Lin <[email protected]>
Date: 2016-04-27T02:19:14Z
constructNextBatch() before runBatch()
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]