jzhuge commented on code in PR #59743:
URL: https://github.com/apache/spark/pull/59743#discussion_r4596649363
##########
sql/core/src/test/scala/org/apache/spark/sql/SparkSessionExtensionSuite.scala:
##########
@@ -513,6 +514,78 @@ class SparkSessionExtensionSuite extends PlanTest with
AdaptiveSparkPlanHelper {
}
}
+ test("SPARK-60483: use the operator default list ahead of user extensions") {
+ val session = SparkSession.builder()
+ .master("local[1]")
+ .config(SPARK_SESSION_EXTENSIONS_DEFAULT_LIST.key,
classOf[MyExtensions].getCanonicalName)
+ .config(SPARK_SESSION_EXTENSIONS.key,
classOf[MyExtensions2].getCanonicalName)
+ .getOrCreate()
+ try {
+ val orderedRules = Seq(MyRule(session), MyRule2(session))
+ val orderedCheckRules = Seq(MyCheckRule(session), MyCheckRule2(session))
+
assert(session.sessionState.analyzer.extendedResolutionRules.containsSlice(orderedRules))
+
assert(session.sessionState.analyzer.extendedCheckRules.containsSlice(orderedCheckRules))
+ assert(session.sessionState.planner.strategies.containsSlice(
+ Seq(MySparkStrategy(session), MySparkStrategy2(session))))
+ } finally {
+ stop(session)
+ }
+ }
+
+ test("SPARK-60483: use the operator default list when user extensions are
unset") {
+ val session = SparkSession.builder()
+ .master("local[1]")
+ .config(SPARK_SESSION_EXTENSIONS_DEFAULT_LIST.key,
classOf[MyExtensions].getCanonicalName)
+ .getOrCreate()
+ try {
+
assert(session.sessionState.analyzer.extendedResolutionRules.contains(MyRule(session)))
+
assert(session.sessionState.planner.strategies.contains(MySparkStrategy(session)))
+ } finally {
+ stop(session)
+ }
+ }
+
+ test("SPARK-60483: an extension listed by both the operator and the user is
applied once") {
+ // De-duplicated across the two lists (last-win); repeats within a single
list stay allowed.
+ val session = SparkSession.builder()
+ .master("local[1]")
+ .config(SPARK_SESSION_EXTENSIONS_DEFAULT_LIST.key,
classOf[MyExtensions].getCanonicalName)
+ .config(SPARK_SESSION_EXTENSIONS.key,
classOf[MyExtensions].getCanonicalName)
+ .getOrCreate()
+ try {
+ assert(session.sessionState.analyzer.extendedResolutionRules.count(_ ===
MyRule(session)) ===
+ 1)
+ } finally {
+ stop(session)
+ }
+ }
+
+ test("SPARK-60483: a shared extension is applied last-win with user-list
repeats kept") {
+ // The shared extension must run only at its user-list positions; plain
concatenation,
+ // first-win, and whole-list distinct all give a different rule order here.
+ val appender = new LogAppender("SPARK-60483 dedup warning")
+ withLogAppender(appender) {
+ val session = SparkSession.builder()
+ .master("local[1]")
+ .config(SPARK_SESSION_EXTENSIONS_DEFAULT_LIST.key,
classOf[MyExtensions].getCanonicalName)
Review Comment:
Filed the follow-up as
[SPARK-61843](https://issues.apache.org/jira/browse/SPARK-61843): your two
cases with the exact counts, plus the disjoint zero-warning assertion, the
`getOption` / `SET` behaviour when only the default list is set, and the
static-config guard. Resolving this thread now that the ticket exists.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]