Skip to content

Commit f516168

Browse files
committed
detect AT_TIMESTAMP
1 parent d5ba012 commit f516168

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/main/scala/org/apache/spark/sql/kinesis/KinesisSourceRDD.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,18 @@ private[kinesis] class KinesisSourceRDD(
165165
}
166166

167167
def canFetchMoreRecords(currentTimestamp: Long): Boolean = {
168-
currentTimestamp - startTimestamp < maxFetchTimeInMs
168+
val iteratorType: String = sourcePartition.shardInfo.iteratorType
169+
if (lastReadSequenceNumber.isEmpty && !(iteratorType == "AT_TIMESTAMP")) {
170+
// We are not using timestamp as offset. So we have to make sure that
171+
// a) we reach the tip of the stream if we have not able to
172+
// b) we read at-least one records
173+
// so that we are never stuck in the loop where we have data near the tip of the stream
174+
// but we are not spending enough time to read it
175+
true
176+
} else {
177+
// honour the maxFetchTime provided in the options.
178+
currentTimestamp - startTimestamp < maxFetchTimeInMs
179+
}
169180
}
170181

171182
def addDelayInFetchingRecords(currentTimestamp: Long): Unit = {

0 commit comments

Comments
 (0)