Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9215#discussion_r42775206
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/util/DataFrameCallbackSuite.scala 
---
    @@ -80,4 +80,24 @@ class DataFrameCallbackSuite extends QueryTest with 
SharedSQLContext {
         assert(metrics(0)._2.analyzed.isInstanceOf[Project])
         assert(metrics(0)._3.getMessage == e.getMessage)
       }
    +
    +  test("get metrics by callback") {
    +    val metrics = ArrayBuffer.empty[Long]
    +    val listener = new QueryExecutionListener {
    +      // Only test successful case here, so no need to implement 
`onFailure`
    +      override def onFailure(funcName: String, qe: QueryExecution, 
exception: Exception): Unit = {}
    +
    +      override def onSuccess(funcName: String, qe: QueryExecution, 
duration: Long): Unit = {
    +        metrics += qe.executedPlan.longMetric("numInputRows").value.value
    +      }
    +    }
    +    sqlContext.listenerManager.register(listener)
    +
    +    Seq(1 -> "a").toDF("i", "j").groupBy("i").count().collect()
    +    Seq(1 -> "a", 2 -> "a").toDF("i", "j").groupBy("i").count().collect()
    +
    +    assert(metrics.length == 2)
    +    assert(metrics(0) == 1)
    +    assert(metrics(1) == 2)
    +  }
    --- End diff --
    
    Can we run the same plan physical plan multiple times to make sure metrics 
are good?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to