Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/20097#discussion_r159114315
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/MicroBatchExecution.scala
---
@@ -236,14 +257,31 @@ class MicroBatchExecution(
val hasNewData = {
awaitProgressLock.lock()
try {
- val latestOffsets: Map[Source, Option[Offset]] = uniqueSources.map
{
+ val latestOffsets: Map[BaseStreamingSource, Option[Offset]] =
uniqueSources.map {
case s: Source =>
updateStatusMessage(s"Getting offsets from $s")
reportTimeTaken("getOffset") {
(s, s.getOffset)
}
+ case s: MicroBatchReader =>
+ updateStatusMessage(s"Getting offsets from $s")
+ reportTimeTaken("getOffset") {
+ // Once v1 streaming source execution is gone, we can
restructure this to be cleaner.
+ // For now, we set the range here to get the available end
offset, and set it again
+ // for real when executing.
+ if (availableOffsets.get(s).isDefined) {
+ val offsetJson = availableOffsets.get(s).get.json
+ s.setOffsetRange(
+ Optional.of(s.deserializeOffset(offsetJson)),
--- End diff --
This code can be simplified further simplified if there is a conversion
from Option to Optional.
```
s.setOffsetRange(availableOffsets.get(s).map(s.deserializedOffset).toOptional,
Optional.empty())
```
maybe add a implicit conversion class for that. would help in other places
as well when you have done `Optional.ofNullable(someOption.orNull)`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]