Skip to content

Commit 5c0c0f8

Browse files
committed
Add deduplicate test when row contains nested columns
1 parent 8790a2d commit 5c0c0f8

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

sql/pipelines/src/test/scala/org/apache/spark/sql/pipelines/autocdc/Scd1BatchProcessorSuite.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,34 @@ class Scd1BatchProcessorSuite extends QueryTest with SharedSparkSession {
229229
)
230230
}
231231

232+
test("deduplicateMicrobatch carries nested columns correctly from the winning row") {
233+
val payloadType = new StructType()
234+
.add("name", StringType)
235+
.add("amount", IntegerType)
236+
val schema = new StructType()
237+
.add("id", IntegerType)
238+
.add("seq", LongType)
239+
.add("payload", payloadType)
240+
241+
val batch = microbatchOf(schema)(
242+
Row(1, 10L, Row("old", 100)),
243+
Row(1, 20L, Row("new", 200))
244+
)
245+
246+
val processor = Scd1BatchProcessor(
247+
changeArgs = ChangeArgs(
248+
keys = Seq(UnqualifiedColumnName("id")),
249+
sequencing = F.col("seq"),
250+
storedAsScdType = ScdType.Type1
251+
)
252+
)
253+
254+
checkAnswer(
255+
df = processor.deduplicateMicrobatch(batch),
256+
expectedAnswer = Row(1, 20L, Row("new", 200))
257+
)
258+
}
259+
232260
test("deduplicateMicrobatch supports composite (multi-column) keys") {
233261
val schema = new StructType()
234262
.add("region", StringType)

0 commit comments

Comments
 (0)