HeartSaVioR commented on code in PR #60313:
URL: https://github.com/apache/spark/pull/60313#discussion_r4591864491
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/ExternalLookupJoinSuite.scala:
##########
@@ -5574,28 +5764,212 @@ class ExternalLookupJoinRealTimeModeSuite extends
StreamRealTimeModeE2ESuiteBase
}
}
- test("real-time mode rejects external lookup join") {
- SimpleExternalLookupDataSource.resetCounters()
- val input = LowLatencyMemoryStream[Int](2)
- val left = input.toDF().toDF("id")
- val lookup =
spark.read.format(classOf[SimpleExternalLookupDataSource].getName).load()
- val joined = left.join(lookup, left("id") === lookup("id"))
- .select(concat(col("department"), lit("-"),
left("id").cast("string")).as("output"))
+ Seq("inner", "left_outer", "left_semi", "left_anti").foreach { joinType =>
+ test(s"real-time mode sends each stream row's lookup request as it reads
the row: $joinType") {
+ val clock = useManualClock()
+ val input = LowLatencyMemoryStream.singlePartition[Int]
+ val query = startJoin(s"external_lookup_rtm_one_row_$joinType",
joinType, input,
+ lookupTable(maxBatchSize = 2))
+ try {
+ // The source allows two stream rows per request, but by default a
real-time request
+ // takes one, so the join sends it and emits its output as soon as it
reads the row, with
+ // the batch still running. Key 3 has no lookup row, so the inner and
left semi joins emit
+ // nothing for it, but its request is still sent.
+ val ids = Seq(1, 3, 2, 4)
+ ids.indices.foreach { n =>
+ input.addData(ids(n))
+ awaitQuery(query) {
+ SimpleExternalLookupDataSource.requestCount.get() == n + 1 &&
+ outputs.sorted == joinOutputs(joinType, ids.take(n + 1):
_*).sorted
+ }
+ }
+ assert(SimpleExternalLookupDataSource.requestSizes.asScala.toSeq ===
Seq(1, 1, 1, 1))
+ endBatch(query, clock)
+ awaitOutputs(query, joinOutputs(joinType, ids: _*))
+ assert(SimpleExternalLookupDataSource.requestCount.get() === 4)
+ } finally {
+ query.stop()
+ }
+ assert(query.exception.isEmpty)
+ }
+
+ test(s"real-time mode fills a request of more rows before it sends it:
$joinType") {
Review Comment:
> [!NOTE]
> **DISCLAIMER:** This comment was written by an LLM, Claude Opus 5.5
(`claude-opus-5-5`, 1M context), posting on behalf of @HeartSaVioR.
Agreed. Done in
[6e8baf0b668](https://github.com/apache/spark/commit/6e8baf0b66801dbd10e275191b543d7924ed8f43):
the test now runs for an inner join only, with a comment that says why one
join type is enough.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]