Skip to content

Commit f3de01f

Browse files
committed
fix
1 parent 052d0d1 commit f3de01f

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,22 @@ abstract class CometTestBase
177177

178178
/** Check for the correct results as well as the expected fallback reason */
179179
def checkSparkAnswerAndFallbackReason(df: => DataFrame, fallbackReason: String): Unit = {
180-
val (_, cometPlan) = checkSparkAnswer(df)
181-
val fallbacks = new ExtendedExplainInfo().getFallbackReasons(cometPlan)
182-
assert(
183-
fallbacks.contains(fallbackReason),
184-
s"Expected fallback reason not found.\nExpected: [$fallbackReason]\nObserved: ${fallbacks
185-
.mkString("[", " | ", "]")}")
180+
checkSparkAnswerAndFallbackReasons(df, Set(fallbackReason))
186181
}
187182

188183
/** Check for the correct results as well as the expected fallback reasons */
189184
def checkSparkAnswerAndFallbackReasons(df: => DataFrame, fallbackReasons: Set[String]): Unit = {
190185
val (_, cometPlan) = checkSparkAnswer(df)
191-
val fallbacks = new ExtendedExplainInfo().getFallbackReasons(cometPlan)
186+
val actualFallbacks = new ExtendedExplainInfo().getFallbackReasons(cometPlan)
192187
for (reason <- fallbackReasons) {
193-
assert(
194-
fallbacks.contains(reason),
195-
s"Expected fallback reason not found.\nExpected: [$reason]\nObserved: ${fallbacks
196-
.mkString("[", " | ", "]")}")
188+
if (!actualFallbacks.exists(_.contains(reason))) {
189+
if (actualFallbacks.isEmpty) {
190+
fail(s"Expected fallback reason '$reason' but no fallback reasons were found")
191+
} else {
192+
fail(
193+
s"Expected fallback reason '$reason' not found in [${actualFallbacks.mkString(" | ")}]")
194+
}
195+
}
197196
}
198197
}
199198

0 commit comments

Comments
 (0)