SuccessChanges

Summary

  1. [SPARK-23809][SQL][BACKPORT] Active SparkSession should be set by (commit: 1a537a2ad5647782932337888f5db20a35ec422c) (details)
Commit 1a537a2ad5647782932337888f5db20a35ec422c by gatorsmile
[SPARK-23809][SQL][BACKPORT] Active SparkSession should be set by
getOrCreate
This backports https://github.com/apache/spark/pull/20927 to branch-2.3
## What changes were proposed in this pull request?
Currently, the active spark session is set inconsistently (e.g., in
createDataFrame, prior to query execution). Many places in spark also
incorrectly query active session when they should be calling
activeSession.getOrElse(defaultSession) and so might get None even if a
Spark session exists.
The semantics here can be cleaned up if we also set the active session
when the default session is set.
Related: https://github.com/apache/spark/pull/20926/files
## How was this patch tested?
Unit test, existing test. Note that if
https://github.com/apache/spark/pull/20926 merges first we should also
update the tests there.
Author: Eric Liang <ekl@databricks.com>
Closes #20971 from ericl/backport-23809.
(commit: 1a537a2ad5647782932337888f5db20a35ec422c)
The file was modifiedsql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala (diff)
The file was modifiedsql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala (diff)
The file was modifiedsql/core/src/test/scala/org/apache/spark/sql/test/TestSQLContext.scala (diff)
The file was modifiedsql/core/src/test/scala/org/apache/spark/sql/SparkSessionBuilderSuite.scala (diff)