diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala index 4a5201735fbd..46ef7943739c 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala @@ -169,7 +169,9 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession { withSQLConf(SQLConf.UTC_TIMESTAMP_FUNC_ENABLED.key -> "true") { spark.sessionState.functionRegistry.listFunction().par.foreach { funcId => - val info = spark.sessionState.catalog.lookupFunctionInfo(funcId) + // Examples can change settings. We clone the session to prevent tests clashing. + val clonedSpark = spark.cloneSession() + val info = clonedSpark.sessionState.catalog.lookupFunctionInfo(funcId) val className = info.getClassName if (!ignoreSet.contains(className)) { withClue(s"Function '${info.getName}', Expression class '$className'") { @@ -177,7 +179,7 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession { checkExampleSyntax(example) example.split(" > ").toList.foreach(_ match { case exampleRe(sql, output) => - val df = spark.sql(sql) + val df = clonedSpark.sql(sql) val actual = unindentAndTrim( hiveResultString(df.queryExecution.executedPlan).mkString("\n")) val expected = unindentAndTrim(output)