This is an automated email from the ASF dual-hosted git repository.
sarutak pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new 49b438df232a [SPARK-57297][SQL][TESTS] Add a test that SQL execution
description respects `spark.sql.redaction.string.regex`
49b438df232a is described below
commit 49b438df232a19ad9227e86c1c89a999fc24e751
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Sun Jun 7 22:43:10 2026 +0900
[SPARK-57297][SQL][TESTS] Add a test that SQL execution description
respects `spark.sql.redaction.string.regex`
### What changes were proposed in this pull request?
This PR adds a test to `SQLExecutionSuite` that verifies the SQL execution
description (`SparkListenerSQLExecutionStart.description`) is redacted
according to `spark.sql.redaction.string.regex`.
### Why are the changes needed?
`SQLExecution` redacts the job description before it is recorded in
`SparkListenerSQLExecutionStart`, but there is no test covering this behavior.
This test guards the redaction so it is not accidentally dropped.
### Does this PR introduce _any_ user-facing change?
No. This is a test-only change.
### How was this patch tested?
Pass the CI with the newly added test.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)
Closes #56358 from dongjoon-hyun/SPARK-57297.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Kousuke Saruta <[email protected]>
(cherry picked from commit 4bc7196c940166e2aec1df3ca205bedaa3291cf6)
Signed-off-by: Kousuke Saruta <[email protected]>
---
.../spark/sql/execution/SQLExecutionSuite.scala | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala
index a85adc9ebf81..638d69fd7191 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLExecutionSuite.scala
@@ -33,6 +33,7 @@ import org.apache.spark.sql.catalyst.SQLConfHelper
import org.apache.spark.sql.catalyst.plans.logical.OneRowRelation
import org.apache.spark.sql.classic
import org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionStart
+import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._
import org.apache.spark.util.ThreadUtils
import org.apache.spark.util.Utils.REDACTION_REPLACEMENT_TEXT
@@ -396,6 +397,30 @@ class SQLExecutionSuite extends SparkFunSuite with
SQLConfHelper {
spark.stop()
}
}
+
+ test("SQL execution description should respect
spark.sql.redaction.string.regex") {
+ val spark =
SparkSession.builder().master("local[*]").appName("test").getOrCreate()
+ try {
+ withSQLConf(SQLConf.SQL_STRING_REDACTION_PATTERN.key ->
"password=([^\\s]+)") {
+ var sqlExecutionDescription: String = null
+ spark.sparkContext.addSparkListener(new SparkListener {
+ override def onOtherEvent(event: SparkListenerEvent): Unit = event
match {
+ case e: SparkListenerSQLExecutionStart =>
+ sqlExecutionDescription = e.description
+ case _ =>
+ }
+ })
+
+ val sqlStatement = "SELECT 'password=secret123'"
+ spark.sparkContext.setJobDescription(sqlStatement)
+ spark.sql(sqlStatement).collect()
+ spark.sparkContext.listenerBus.waitUntilEmpty()
+ assert(sqlExecutionDescription === s"SELECT
'$REDACTION_REPLACEMENT_TEXT")
+ }
+ } finally {
+ spark.stop()
+ }
+ }
}
object SQLExecutionSuite {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]