Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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 @@ -43,7 +43,7 @@ class AnalysisException protected[sql] (
}

override def getMessage: String = {
val planAnnotation = plan.map(p => s";\n$p").getOrElse("")
val planAnnotation = Option(plan).map(p => s";\n$p").getOrElse("")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my fault. We need another flatten.

    val planAnnotation = Option(plan).flatten.map(p => s";\n$p").getOrElse("")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, updated.

getSimpleMessage + planAnnotation
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2598,4 +2598,12 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
}
assert(!jobStarted.get(), "Command should not trigger a Spark job.")
}

test("SPARK-20164: AnalysisException should be tolerant to null query plan") {
try {
throw new AnalysisException("", None, None, plan = null)
} catch {
case ae: AnalysisException => assert(ae.plan == null && ae.getMessage == ae.getSimpleMessage)
}
}
}