You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/12/11 17:29:13 UTC
[GitHub] [spark] MaxGekk commented on a change in pull request #30724: [SPARK-33752][SQL] Avoid the getSimpleMessage of AnalysisException adds semicolon repeatedly
MaxGekk commented on a change in pull request #30724:
URL: https://github.com/apache/spark/pull/30724#discussion_r541108934
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -48,9 +48,11 @@ class AnalysisException protected[sql] (
// Outputs an exception without the logical plan.
// For testing only
- def getSimpleMessage: String = {
+ def getSimpleMessage: String = if (line.isDefined || startPosition.isDefined) {
val lineAnnotation = line.map(l => s" line $l").getOrElse("")
val positionAnnotation = startPosition.map(p => s" pos $p").getOrElse("")
s"$message;$lineAnnotation$positionAnnotation"
+ } else {
+ message
Review comment:
You could avoid the branch:
```scala
val linePosAnnotation = line.map(l => s" line $l").getOrElse("") + startPosition.map(p => s" pos $p").getOrElse("")
val sep = if (linePosAnnotation.isEmpty) "" else ";"
s"$message$sep$linePosAnnotation"
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org