Skip to content

Commit c29c443

Browse files
committed
[KYUUBI #1786] Fix the Spark sql engine logger level changed to WARN issue
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> To close #1786 Main object will init logger with isInterpreter=true, which changes logger to WARN level. In this pr, we do not use Main.output as `spark.repl.class.outputDir` ### _How was this patch tested?_ Passed existing tests. Closes #1828 from turboFei/repl_warn. Closes #1786 91fc327 [Fei Wang] address commments 762d148 [Fei Wang] refactor 4e18f36 [Fei Wang] do not use main output dir Authored-by: Fei Wang <fwang12@ebay.com> Signed-off-by: Fei Wang <fwang12@ebay.com>
1 parent 68f70fd commit c29c443

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import scala.util.control.NonFatal
2424

2525
import org.apache.spark.{ui, SparkConf}
2626
import org.apache.spark.kyuubi.SparkSQLEngineListener
27-
import org.apache.spark.repl.Main
27+
import org.apache.spark.kyuubi.SparkUtilsHelper.getLocalDir
2828
import org.apache.spark.sql.SparkSession
2929

30-
import org.apache.kyuubi.{KyuubiException, Logging}
30+
import org.apache.kyuubi.{KyuubiException, Logging, Utils}
3131
import org.apache.kyuubi.Utils._
3232
import org.apache.kyuubi.config.KyuubiConf
3333
import org.apache.kyuubi.config.KyuubiConf._
@@ -78,13 +78,15 @@ object SparkSQLEngine extends Logging {
7878

7979
def createSpark(): SparkSession = {
8080
val sparkConf = new SparkConf()
81+
val rootDir = sparkConf.getOption("spark.repl.classdir").getOrElse(getLocalDir(sparkConf))
82+
val outputDir = Utils.createTempDir(root = rootDir, namePrefix = "repl")
8183
sparkConf.setIfMissing("spark.sql.execution.topKSortFallbackThreshold", "10000")
8284
sparkConf.setIfMissing("spark.sql.legacy.castComplexTypesToString.enabled", "true")
8385
sparkConf.setIfMissing("spark.master", "local")
8486
sparkConf.setIfMissing("spark.ui.port", "0")
8587
// register the repl's output dir with the file server.
8688
// see also `spark.repl.classdir`
87-
sparkConf.set("spark.repl.class.outputDir", Main.outputDir.getAbsolutePath)
89+
sparkConf.set("spark.repl.class.outputDir", outputDir.toFile.getAbsolutePath)
8890
sparkConf.setIfMissing(
8991
"spark.hadoop.mapreduce.input.fileinputformat.list-status.num-threads",
9092
"20")

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/repl/KyuubiSparkILoop.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import scala.tools.nsc.interpreter.IR
2424
import scala.tools.nsc.interpreter.JPrintWriter
2525

2626
import org.apache.spark.SparkContext
27-
import org.apache.spark.repl.{Main, SparkILoop}
27+
import org.apache.spark.repl.SparkILoop
2828
import org.apache.spark.sql.{DataFrame, SparkSession}
2929
import org.apache.spark.util.MutableURLClassLoader
3030

@@ -40,7 +40,7 @@ private[spark] case class KyuubiSparkILoop private (
4040
val interpArguments = List(
4141
"-Yrepl-class-based",
4242
"-Yrepl-outdir",
43-
s"${Main.outputDir.getAbsolutePath}")
43+
s"${spark.sparkContext.getConf.get("spark.repl.class.outputDir")}")
4444
settings.processArguments(interpArguments, processAll = true)
4545
settings.usejavacp.value = true
4646
val currentClassLoader = Thread.currentThread().getContextClassLoader

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/kyuubi/SparkUtilsHelper.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.apache.spark.kyuubi
1919

2020
import scala.util.matching.Regex
2121

22+
import org.apache.spark.SparkConf
2223
import org.apache.spark.util.Utils
2324

2425
import org.apache.kyuubi.Logging
@@ -35,4 +36,11 @@ object SparkUtilsHelper extends Logging {
3536
def redact(regex: Option[Regex], text: String): String = {
3637
Utils.redact(regex, text)
3738
}
39+
40+
/**
41+
* Get the path of a temporary directory.
42+
*/
43+
def getLocalDir(conf: SparkConf): String = {
44+
Utils.getLocalDir(conf)
45+
}
3846
}

0 commit comments

Comments
 (0)