Github user vanzin commented on a diff in the pull request: https://github.com/apache/spark/pull/16664#discussion_r99032021 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/util/DataFrameCallbackSuite.scala --- @@ -114,6 +138,55 @@ class DataFrameCallbackSuite extends QueryTest with SharedSQLContext { spark.listenerManager.unregister(listener) } + test("QueryExecutionListener gets called on DataFrameWriter.parquet method") { + callSave("parquet", (df: DataFrame, path: String) => df.write.parquet(path)) + } + + test("QueryExecutionListener gets called on DataFrameWriter.json method") { + callSave("json", (df: DataFrame, path: String) => df.write.json(path)) + } + + test("QueryExecutionListener gets called on DataFrameWriter.csv method") { + callSave("csv", (df: DataFrame, path: String) => df.write.csv(path)) + } + + test("QueryExecutionListener gets called on DataFrameWriter.saveAsTable method") { + var onWriteSuccessCalled = false + spark.listenerManager.register(new QueryExecutionListener { + + override def onFailure( + funcName: String, + qe: QueryExecution, + exception: Exception, + outputParams: Option[OutputParams]): Unit = {} + + override def onSuccess( + funcName: String, + qe: QueryExecution, + durationNs: Long, + outputParams: Option[OutputParams]): Unit = { + assert(durationNs > 0) + assert(qe ne null) + onWriteSuccessCalled = true + } + }) + withTable("bar") { + Seq(1 -> 100).toDF("x", "y").write.saveAsTable("bar") + } + assert(onWriteSuccessCalled) + spark.listenerManager.clear() --- End diff -- This needs to be in a finally block no?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org