cloud-fan commented on code in PR #53777:
URL: https://github.com/apache/spark/pull/53777#discussion_r2685067033
##########
sql/core/src/test/scala/org/apache/spark/sql/SparkSessionBuilderSuite.scala:
##########
@@ -598,4 +598,65 @@ class SparkSessionBuilderSuite extends SparkFunSuite with
Eventually {
.getOrCreate()
assert(session.sparkContext.appName === "newAppName")
}
+
+ test("SPARK-55016: isSessionStateInitialized flag should track sessionState
initialization") {
+ val session = SparkSession.builder()
+ .master("local")
+ .appName("test-session-state-init")
+ .getOrCreate()
+ .asInstanceOf[classic.SparkSession]
+
+ try {
+ // Before accessing sessionState, the flag should be false
+ assert(!session.isSessionStateInitialized,
+ "sessionState should not be initialized before first access")
+
+ // Access sessionState to trigger initialization
+ val _ = session.sessionState
+
+ // After accessing sessionState, the flag should be true
+ assert(session.isSessionStateInitialized,
+ "sessionState should be marked as initialized after access")
+ } finally {
+ session.stop()
+ }
+ }
+
+ test("SPARK-55016: SQLConf.get should return fallback conf " +
+ "when sessionState is not initialized") {
+ val session = SparkSession.builder()
+ .master("local")
+ .appName("test-sqlconf-fallback")
+ .getOrCreate()
+ .asInstanceOf[classic.SparkSession]
+
+ try {
+ // Before accessing sessionState, SQLConf.get should return fallback conf
+ assert(!session.isSessionStateInitialized,
+ "sessionState should not be initialized before first access")
+
+ val conf = SQLConf.get
+ val fallbackConf = SQLConf.getFallbackConf
+
+ // When sessionState is not initialized, SQLConf.get should equal
fallback conf
+ assert(conf == fallbackConf,
Review Comment:
shall we check the reference? `conf.eq(fallbackConf)`
--
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]