Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down