Skip to content

Commit

Permalink
Clone SparkSession per each function
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGekk committed Sep 28, 2019
1 parent d72f398 commit 75fe88d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,17 @@ 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'") {
val example = info.getExamples
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)
Expand Down

0 comments on commit 75fe88d

Please sign in to comment.