Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-13828][SQL] Bring back stack trace of AnalysisException thrown from QueryExecution.assertAnalyzed #11677

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class QueryExecution(val sqlContext: SQLContext, val logical: LogicalPlan) {

def assertAnalyzed(): Unit = try sqlContext.analyzer.checkAnalysis(analyzed) catch {
case e: AnalysisException =>
throw new AnalysisException(e.message, e.line, e.startPosition, Some(analyzed))
val ae = new AnalysisException(e.message, e.line, e.startPosition, Some(analyzed))
ae.setStackTrace(e.getStackTrace)
throw ae
}

lazy val analyzed: LogicalPlan = sqlContext.analyzer.execute(logical)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import scala.util.Random
import org.scalatest.Matchers._

import org.apache.spark.SparkException
import org.apache.spark.sql.catalyst.plans.logical.{BroadcastHint, OneRowRelation, Union}
import org.apache.spark.sql.catalyst.plans.logical.{OneRowRelation, Union}
import org.apache.spark.sql.execution.QueryExecution
import org.apache.spark.sql.execution.aggregate.TungstenAggregate
import org.apache.spark.sql.execution.exchange.{BroadcastExchange, ReusedExchange, ShuffleExchange}
import org.apache.spark.sql.functions._
Expand Down Expand Up @@ -1366,4 +1367,12 @@ class DataFrameSuite extends QueryTest with SharedSQLContext {
// another invalid table name test as below
intercept[AnalysisException](df.registerTempTable("table!#"))
}

test("assertAnalyzed shouldn't replace original stack trace") {
val e = intercept[AnalysisException] {
sqlContext.range(1).select('id as 'a, 'id as 'b).groupBy('a).agg('b)
}

assert(e.getStackTrace.head.getClassName != classOf[QueryExecution].getName)
}
}