@@ -1299,16 +1299,18 @@ private[spark] object Utils extends Logging {
12991299 }
13001300
13011301 /** Default filtering function for finding call sites using `getCallSite`. */
1302- private def coreExclusionFunction (className : String ): Boolean = {
1303- // A regular expression to match classes of the "core" Spark API that we want to skip when
1304- // finding the call site of a method.
1302+ private def sparkInternalExclusionFunction (className : String ): Boolean = {
1303+ // A regular expression to match classes of the internal Spark API's
1304+ // that we want to skip when finding the call site of a method.
13051305 val SPARK_CORE_CLASS_REGEX =
13061306 """ ^org\.apache\.spark(\.api\.java)?(\.util)?(\.rdd)?(\.broadcast)?\.[A-Z]""" .r
1307+ val SPARK_SQL_CLASS_REGEX = """ ^org\.apache\.spark\.sql.*""" .r
13071308 val SCALA_CORE_CLASS_PREFIX = " scala"
1308- val isSparkCoreClass = SPARK_CORE_CLASS_REGEX .findFirstIn(className).isDefined
1309+ val isSparkClass = SPARK_CORE_CLASS_REGEX .findFirstIn(className).isDefined ||
1310+ SPARK_SQL_CLASS_REGEX .findFirstIn(className).isDefined
13091311 val isScalaClass = className.startsWith(SCALA_CORE_CLASS_PREFIX )
13101312 // If the class is a Spark internal class or a Scala class, then exclude.
1311- isSparkCoreClass || isScalaClass
1313+ isSparkClass || isScalaClass
13121314 }
13131315
13141316 /**
@@ -1318,7 +1320,7 @@ private[spark] object Utils extends Logging {
13181320 *
13191321 * @param skipClass Function that is used to exclude non-user-code classes.
13201322 */
1321- def getCallSite (skipClass : String => Boolean = coreExclusionFunction ): CallSite = {
1323+ def getCallSite (skipClass : String => Boolean = sparkInternalExclusionFunction ): CallSite = {
13221324 // Keep crawling up the stack trace until we find the first function not inside of the spark
13231325 // package. We track the last (shallowest) contiguous Spark method. This might be an RDD
13241326 // transformation, a SparkContext function (such as parallelize), or anything else that leads
@@ -1357,9 +1359,17 @@ private[spark] object Utils extends Logging {
13571359 }
13581360
13591361 val callStackDepth = System .getProperty(" spark.callstack.depth" , " 20" ).toInt
1360- CallSite (
1361- shortForm = s " $lastSparkMethod at $firstUserFile: $firstUserLine" ,
1362- longForm = callStack.take(callStackDepth).mkString(" \n " ))
1362+ val shortForm =
1363+ if (firstUserFile == " HiveSessionImpl.java" ) {
1364+ // To be more user friendly, show a nicer string for queries submitted from the JDBC
1365+ // server.
1366+ " Spark JDBC Server Query"
1367+ } else {
1368+ s " $lastSparkMethod at $firstUserFile: $firstUserLine"
1369+ }
1370+ val longForm = callStack.take(callStackDepth).mkString(" \n " )
1371+
1372+ CallSite (shortForm, longForm)
13631373 }
13641374
13651375 /** Return a string containing part of a file from byte 'start' to 'end'. */
0 commit comments