HeartSaVioR commented on a change in pull request #23747:
[SPARK-26848][SQL][SS] Introduce new option to Kafka source: offset by
timestamp (starting/ending)
URL: https://github.com/apache/spark/pull/23747#discussion_r324865820
##########
File path:
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/JsonUtils.scala
##########
@@ -68,20 +68,35 @@ private object JsonUtils {
partOffsets.map { case (part, offset) =>
new TopicPartition(topic, part) -> offset
}
- }.toMap
+ }
} catch {
case NonFatal(x) =>
throw new IllegalArgumentException(
s"""Expected e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}, got
$str""")
}
}
+ def partitionTimestamps(str: String): Map[TopicPartition, Long] = {
+ try {
+ Serialization.read[Map[String, Map[Int, Long]]](str).flatMap { case
(topic, partTimestamps) =>
+ partTimestamps.map { case (part, timestamp) =>
+ new TopicPartition(topic, part) -> timestamp
+ }
+ }
+ } catch {
+ case NonFatal(x) =>
+ throw new IllegalArgumentException(
+ s"""Expected e.g. {"topicA": {"0": 1549597128110, "1":
1549597128110},
Review comment:
Hmm... that's consistent exception message with `partitionOffsets`, as it
provides hard-code values to represent example of input. (These values just
look oddly long, as they're representing timestamp.) Do you have suggestion to
make it better?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]