You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "juliuszsompolski (via GitHub)" <gi...@apache.org> on 2023/07/29 13:16:20 UTC

[GitHub] [spark] juliuszsompolski commented on a diff in pull request #42216: [SPARK-44591][CONNECT][SQL] Add jobTags to SparkListenerSQLExecutionStart

juliuszsompolski commented on code in PR #42216:
URL: https://github.com/apache/spark/pull/42216#discussion_r1278296020


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala:
##########
@@ -203,6 +203,35 @@ class SQLExecutionSuite extends SparkFunSuite {
       spark.stop()
     }
   }
+
+  test("jobTags property.") {
+    val spark = SparkSession.builder.master("local[*]").appName("test").getOrCreate()
+
+    // Disable Photon as the test uses a local spark session and hence JNI is not initialized.
+    val jobTag = "jobTag"
+    spark.sparkContext.addJobTag(jobTag)
+
+    var jobTags: Option[String] = None
+    var sqlJobTags: Set[String] = Set.empty
+    spark.sparkContext.addSparkListener(new SparkListener {
+      override def onJobStart(jobStart: SparkListenerJobStart): Unit = {
+        jobTags = Some(jobStart.properties.getProperty(SparkContext.SPARK_JOB_TAGS))
+      }
+      override def onOtherEvent(event: SparkListenerEvent): Unit = {
+        event match {
+          case e: SparkListenerSQLExecutionStart =>
+            sqlJobTags = e.jobTags
+        }
+      }
+    })
+
+    spark.range(1).collect()
+
+    assert(jobTags.contains(jobTag))
+    assert(sqlJobTags.contains(jobTag))
+
+    spark.stop()

Review Comment:
   other tests around here seem to wrap in try and do spark.stop() in finally.
   Could you also do spark.sparkContext.removeJobTag(jobTag) in the finally, as otherwise I think the SparkContext gets shared between tests and the tag can get leaked into other tests?



##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala:
##########
@@ -203,6 +203,35 @@ class SQLExecutionSuite extends SparkFunSuite {
       spark.stop()
     }
   }
+
+  test("jobTags property.") {
+    val spark = SparkSession.builder.master("local[*]").appName("test").getOrCreate()
+
+    // Disable Photon as the test uses a local spark session and hence JNI is not initialized.

Review Comment:
   nit: this comment seems unrelated and accidentally copied over from somewhere.



##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala:
##########
@@ -203,6 +203,35 @@ class SQLExecutionSuite extends SparkFunSuite {
       spark.stop()
     }
   }
+
+  test("jobTags property.") {

Review Comment:
   nit: remove "." from test name



-- 
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-unsubscribe@spark.apache.org

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