HeartSaVioR commented on a change in pull request #26768: [SPARK-30141][SQL][TESTS] Fix QueryTest.checkAnswer usage URL: https://github.com/apache/spark/pull/26768#discussion_r354721676
########## File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/binaryfile/BinaryFileFormatSuite.scala ########## @@ -352,15 +352,24 @@ class BinaryFileFormatSuite extends QueryTest with SharedSparkSession { .select(CONTENT) } val expected = Seq(Row(content)) - QueryTest.checkAnswer(readContent(), expected) + QueryTest.checkAnswer(readContent(), expected) match { + case Some(errorMessage) => fail(errorMessage) + case None => + } withSQLConf(SOURCES_BINARY_FILE_MAX_LENGTH.key -> content.length.toString) { - QueryTest.checkAnswer(readContent(), expected) + QueryTest.checkAnswer(readContent(), expected) match { + case Some(errorMessage) => fail(errorMessage) + case None => + } } // Disable read. If the implementation attempts to read, the exception would be different. file.setReadable(false) val caught = intercept[SparkException] { withSQLConf(SOURCES_BINARY_FILE_MAX_LENGTH.key -> (content.length - 1).toString) { - QueryTest.checkAnswer(readContent(), expected) + QueryTest.checkAnswer(readContent(), expected) match { Review comment: I think @HyukjinKwon's suggestion would be better for future modification in point of preventing the cause, if there's no actual usage of `QueryTest.checkAnswer` from outside of `QueryTest`. (I guess it might have been misused like this PR fixes...) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org