Skip to content

Commit eb2adde

Browse files
cloud-fandongjoon-hyun
authored andcommitted
[SPARK-54835][SQL][TESTS][FOLLOWUP] Drain listener bus before registering listener in test
### What changes were proposed in this pull request? This is a followup to #53596. In the test "CTAS/RTAS should trigger two query executions", we drain the listener bus before registering the `QueryExecutionListener`, to avoid events from other tests breaking this test with unexpected `executionCount` increments. ### Why are the changes needed? Without draining the listener bus first, pending events from previous tests could fire after the listener is registered, causing flaky test failures. Other test suites follow this same pattern. ### Does this PR introduce _any_ user-facing change? No. Test-only change. ### How was this patch tested? Existing test. ### Was this patch authored or co-authored using generative AI tooling? Yes. Made with [Cursor](https://cursor.com) Closes #54397 from cloud-fan/SPARK-54835-followup. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 89aafe6 commit eb2adde

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,8 @@ class DataSourceV2DataFrameSuite
21552155
}
21562156

21572157
try {
2158+
// drain listener bus before registering the listener.
2159+
sparkContext.listenerBus.waitUntilEmpty()
21582160
spark.listenerManager.register(listener)
21592161
val t = "testcat.ns1.ns2.tbl"
21602162
withTable(t) {

0 commit comments

Comments
 (0)