HeartSaVioR commented on a change in pull request #32609:
URL: https://github.com/apache/spark/pull/32609#discussion_r638335286
##########
File path:
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaSourceProvider.scala
##########
@@ -564,20 +575,38 @@ private[kafka010] object KafkaSourceProvider extends
Logging {
def getKafkaOffsetRangeLimit(
params: CaseInsensitiveMap[String],
+ globalOffsetTimestampOptionKey: String,
offsetByTimestampOptionKey: String,
offsetOptionKey: String,
defaultOffsets: KafkaOffsetRangeLimit): KafkaOffsetRangeLimit = {
- params.get(offsetByTimestampOptionKey).map(_.trim) match {
- case Some(json) =>
SpecificTimestampRangeLimit(JsonUtils.partitionTimestamps(json))
- case None =>
- params.get(offsetOptionKey).map(_.trim) match {
- case Some(offset) if offset.toLowerCase(Locale.ROOT) == "latest" =>
- LatestOffsetRangeLimit
- case Some(offset) if offset.toLowerCase(Locale.ROOT) == "earliest" =>
- EarliestOffsetRangeLimit
- case Some(json) =>
SpecificOffsetRangeLimit(JsonUtils.partitionOffsets(json))
- case None => defaultOffsets
- }
+ // The order below represents "preferences"
+
+ // 1. global timestamp
+ if (params.contains(globalOffsetTimestampOptionKey)) {
+ val tsStr = params(globalOffsetTimestampOptionKey).trim
+ try {
+ val ts = tsStr.toLong
+ return GlobalTimestampRangeLimit(ts)
Review comment:
I intended to avoid deeper level of indentations, but if ~ else if ~
else would achieve the same without return. Will address.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]