You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/09/02 02:49:29 UTC

[GitHub] [spark] LuciferYang commented on a change in pull request #29608: [SPARK-32762][SQL][TEST] Enhance the verification of ExpressionsSchemaSuite to sql-expression-schema.md

LuciferYang commented on a change in pull request #29608:
URL: https://github.com/apache/spark/pull/29608#discussion_r481578827



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/ExpressionsSchemaSuite.scala
##########
@@ -161,14 +161,28 @@ class ExpressionsSchemaSuite extends QueryTest with SharedSparkSession {
         s"Expected $expectedSize blocks in result file but got " +
           s"${outputSize + headerSize}. Try regenerate the result files.")
 
-      Seq.tabulate(outputSize) { i =>
+      val numberOfQueries = lines(2).split(":")(1).trim.toInt
+      val numberOfMissExample = lines(3).split(":")(1).trim.toInt
+      val missExamples = lines(4).split(":")(1).trim.split(",")
+      val expectedOutputs = Seq.tabulate(outputSize) { i =>
         val segments = lines(i + headerSize).split('|')
         QueryOutput(
           className = segments(1).trim,
           funcName = segments(2).trim,
           sql = segments(3).trim,
           schema = segments(4).trim)
       }
+
+      // Ensure consistency of the result file.
+      assert(numberOfQueries == expectedOutputs.size,
+        s"outputs size: ${expectedOutputs.size} not same as numberOfQueries: $numberOfQueries " +
+          "record in result file. Try regenerate the result files.")

Review comment:
       ok ~

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/ExpressionsSchemaSuite.scala
##########
@@ -161,14 +161,28 @@ class ExpressionsSchemaSuite extends QueryTest with SharedSparkSession {
         s"Expected $expectedSize blocks in result file but got " +
           s"${outputSize + headerSize}. Try regenerate the result files.")
 
-      Seq.tabulate(outputSize) { i =>
+      val numberOfQueries = lines(2).split(":")(1).trim.toInt
+      val numberOfMissExample = lines(3).split(":")(1).trim.toInt
+      val missExamples = lines(4).split(":")(1).trim.split(",")
+      val expectedOutputs = Seq.tabulate(outputSize) { i =>
         val segments = lines(i + headerSize).split('|')
         QueryOutput(
           className = segments(1).trim,
           funcName = segments(2).trim,
           sql = segments(3).trim,
           schema = segments(4).trim)
       }
+
+      // Ensure consistency of the result file.
+      assert(numberOfQueries == expectedOutputs.size,
+        s"outputs size: ${expectedOutputs.size} not same as numberOfQueries: $numberOfQueries " +
+          "record in result file. Try regenerate the result files.")

Review comment:
       ok ~




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org