diff options
author | Shixiong Zhu <shixiong@databricks.com> | 2016-12-14 13:36:41 -0800 |
---|---|---|
committer | Shixiong Zhu <shixiong@databricks.com> | 2016-12-14 13:36:41 -0800 |
commit | 1ac6567bdb03d7cc5c5f3473827a102280cb1030 (patch) | |
tree | be8018d4e321c590298727fdc73369c3dfcbbd71 /python/pyspark/sql/streaming.py | |
parent | 5d799473696a15fddd54ec71a93b6f8cb169810c (diff) | |
download | spark-1ac6567bdb03d7cc5c5f3473827a102280cb1030.tar.gz spark-1ac6567bdb03d7cc5c5f3473827a102280cb1030.tar.bz2 spark-1ac6567bdb03d7cc5c5f3473827a102280cb1030.zip |
[SPARK-18852][SS] StreamingQuery.lastProgress should be null when recentProgress is empty
## What changes were proposed in this pull request?
Right now `StreamingQuery.lastProgress` throws NoSuchElementException and it's hard to be used in Python since Python user will just see Py4jError.
This PR just makes it return null instead.
## How was this patch tested?
`test("lastProgress should be null when recentProgress is empty")`
Author: Shixiong Zhu <shixiong@databricks.com>
Closes #16273 from zsxwing/SPARK-18852.
Diffstat (limited to 'python/pyspark/sql/streaming.py')
-rw-r--r-- | python/pyspark/sql/streaming.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/python/pyspark/sql/streaming.py b/python/pyspark/sql/streaming.py index 9cfb3fe25c..eabd5ef54c 100644 --- a/python/pyspark/sql/streaming.py +++ b/python/pyspark/sql/streaming.py @@ -125,10 +125,15 @@ class StreamingQuery(object): @since(2.1) def lastProgress(self): """ - Returns the most recent :class:`StreamingQueryProgress` update of this streaming query. + Returns the most recent :class:`StreamingQueryProgress` update of this streaming query or + None if there were no progress updates :return: a map """ - return json.loads(self._jsq.lastProgress().json()) + lastProgress = self._jsq.lastProgress() + if lastProgress: + return json.loads(lastProgress.json()) + else: + return None @since(2.0) def processAllAvailable(self): |