mgaido91 commented on a change in pull request #23258: 
[SPARK-23375][SQL][FOLLOWUP][TEST] Test Sort metrics while Sort is missing
URL: https://github.com/apache/spark/pull/23258#discussion_r244531373
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/metric/SQLMetricsSuite.scala
 ##########
 @@ -194,10 +194,20 @@ class SQLMetricsSuite extends SparkFunSuite with 
SQLMetricsTestUtils with Shared
   }
 
   test("Sort metrics") {
-    // Assume the execution plan is
-    // WholeStageCodegen(nodeId = 0, Range(nodeId = 2) -> Sort(nodeId = 1))
-    val ds = spark.range(10).sort('id)
-    testSparkPlanMetrics(ds.toDF(), 2, Map.empty)
+    // Assume the execution plan with node id is
+    // Sort(nodeId = 0)
+    //   Exchange(nodeId = 1)
+    //     Project(nodeId = 2)
+    //       LocalTableScan(nodeId = 3)
+    // Because of SPARK-25267, ConvertToLocalRelation is disabled in the test 
cases of sql/core,
+    // so Project here is not collapsed into LocalTableScan.
+    val df = Seq(1, 3, 2).toDF("id").sort('id)
+    testSparkPlanMetrics(df, 2, Map(
 
 Review comment:
   Let me clarify. I'd introduce a `testSparkPlanMetricsWithPredicates` as you 
did before (you can take it from your previous commit). And here in the 
predicate we can use the patterns you introduced for checking them, so 
something like:
   ```
      val timingMetricPattern =
        Pattern.compile(s"\\n$duration \\($duration, $duration, $duration\\)")
      val sizeMetricPattern = Pattern.compile(s"\\n$bytes \\($bytes, $bytes, 
$bytes\\)")
      def checkPattern(pattern: Pattern): (Any => Boolean) = {
        (in: Any) => pattern.matcher(in.toString).matches()
      }
      testSparkPlanMetricsWithPredicates(df, 2, Map(
         0L -> (("Sort", Map(
           "sort time total (min, med, max)" -> checkPattern(sizeMetricPattern),
           "peak memory total (min, med, max)" -> 
checkPattern(timingMetricPattern),
           "spill size total (min, med, max)" -> 
checkPattern(sizeMetricPattern))))))
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to