HyukjinKwon commented on code in PR #38685: URL: https://github.com/apache/spark/pull/38685#discussion_r1029966254
########## sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala: ########## @@ -1759,24 +1763,25 @@ class DataFrameSuite extends QueryTest test("SPARK-8072: Better Exception for Duplicate Columns") { // only one duplicate column present - val e = intercept[org.apache.spark.sql.AnalysisException] { + val e = intercept[AnalysisException] { Seq((1, 2, 3), (2, 3, 4), (3, 4, 5)).toDF("column1", "column2", "column1") .write.format("parquet").save("temp") } - assert(e.getMessage.contains("Found duplicate column(s) when inserting into")) - assert(e.getMessage.contains("column1")) - assert(!e.getMessage.contains("column2")) + checkError( + exception = e, + errorClass = "COLUMN_ALREADY_EXISTS", + parameters = Map("columnName" -> "`column1`")) Review Comment: Several tests fixed here seem flaky because of the order in the map, e.g.: ``` - SPARK-8072: Better Exception for Duplicate Columns *** FAILED *** (42 milliseconds) Map("columnName" -> "`column3`") did not equal Map("columnName" -> "`column1`") (SparkFunSuite.scala:317) Analysis: JavaCollectionWrappers$JMapWrapper(columnName: `column3` -> `column1`) org.scalatest.exceptions.TestFailedException: at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472) at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471) at org.scalatest.Assertions$.newAssertionFailedException(Assertions.scala:1231) at org.scalatest.Assertions$AssertionsHelper.macroAssert(Assertions.scala:1295) at org.apache.spark.SparkFunSuite.checkError(SparkFunSuite.scala:317) at org.apache.spark.sql.DataFrameSuite.$anonfun$new$368(DataFrameSuite.scala:1781) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85) at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83) at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104) at org.scalatest.Transformer.apply(Transformer.scala:22) at org.scalatest.Transformer.apply(Transformer.scala:20) at org.scalatest.funsuite.AnyFunSuiteLike$$anon$1.apply(AnyFunSuiteLike.scala:226) at org.apache.spark.SparkFunSuite.withFixture(SparkFunSuite.scala:207) at org.scalatest.funsuite.AnyFunSuiteLike.invokeWithFixture$1(AnyFunSuiteLike.scala:224) ``` https://github.com/apache/spark/actions/runs/3525051044/jobs/5911287739 and https://github.com/apache/spark/actions/runs/3526328003 which happens in a different JDK or Scala version. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org