Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class KinesisV2PartitionReader (schema: StructType,
case "subSequenceNumber" => UTF8String.fromString(record.sequenceNumber.subSequenceNumber.toString)
case "approximateArrivalTimestamp" => ChronoUnit.MICROS.between(Instant.EPOCH, record.approximateArrivalTimestamp)
case "data" => record.data
case "shardId" => UTF8String.fromString(kinesisShardId)
case name =>
throw new UnsupportedOperationException("Unsupported field name in schema " + name)
}.toSeq)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ object KinesisClientFactory {
StructField("streamName", StringType),
StructField("partitionKey", StringType),
StructField("sequenceNumber", StringType),
StructField("approximateArrivalTimestamp", TimestampType))
StructField("approximateArrivalTimestamp", TimestampType),
StructField("shardId", StringType))
)

def createConsumer(options: KinesisOptions, streamName: String, endpointUrl: String): KinesisClientConsumer = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,8 @@ abstract class KinesisSourceItSuite(aggregateTestData: Boolean,
assert(kinesis.schema == KinesisClientFactory.kinesisSchema)

val result = kinesis.selectExpr("CAST(data AS STRING)", "streamName",
"partitionKey", "sequenceNumber", "CAST(approximateArrivalTimestamp AS TIMESTAMP)")
.as[(String, String, String, String, Long)]
"partitionKey", "sequenceNumber", "CAST(approximateArrivalTimestamp AS TIMESTAMP)", "shardId")
.as[(String, String, String, String, Long, String)]

val query = result.writeStream
.format("memory")
Expand All @@ -823,6 +823,7 @@ abstract class KinesisSourceItSuite(aggregateTestData: Boolean,

assert(row.getAs[String]("streamName") === localTestUtils.streamName, s"Unexpected results: $row")
assert(row.getAs[String]("partitionKey") === "1", s"Unexpected results: $row")
assert(localTestUtils.getShards.map(_.getShardId).contains(row.getAs[String]("shardId")), s"Unexpected results: $row")
query.stop()
} finally {
localTestUtils.deleteStream()
Expand Down