[SPARK-25886][SQL][MINOR] Improve error message of FailureSafeParser
and from_avro
in FAILFAST mode
## What changes were proposed in this pull request? Currently in `FailureSafeParser` and `from_avro`, the exception is created with such code ``` throw new SparkException("Malformed records are detected in record parsing. " + s"Parse Mode: ${FailFastMode.name}.", e.cause) ``` 1. The cause part should be `e` instead of `e.cause` 2. If `e` contains non-null message, it should be shown in `from_json`/`from_csv`/`from_avro`, e.g. ``` com.fasterxml.jackson.core.JsonParseException: Unexpected character ('1' (code 49)): was expecting a colon to separate field name and value at [Source: (InputStreamReader); line: 1, column: 7] ``` 3.Kindly show hint for trying PERMISSIVE in error message. ## How was this patch tested? Unit test. Closes #22895 from gengliangwang/improve_error_msg. Authored-by: Gengliang Wang <gengliang.wang@databricks.com> Signed-off-by: hyukjinkwon <gurwls223@apache.org>
This commit is contained in:
parent
3c0e9ce944
commit
57eddc7182
|
@ -102,7 +102,7 @@ case class AvroDataToCatalyst(
|
|||
case FailFastMode =>
|
||||
throw new SparkException("Malformed records are detected in record parsing. " +
|
||||
s"Current parse Mode: ${FailFastMode.name}. To process malformed records as null " +
|
||||
"result, try setting the option 'mode' as 'PERMISSIVE'.", e.getCause)
|
||||
"result, try setting the option 'mode' as 'PERMISSIVE'.", e)
|
||||
case _ =>
|
||||
throw new AnalysisException(unacceptableModeMessage(parseMode.name))
|
||||
}
|
||||
|
|
|
@ -73,7 +73,8 @@ class FailureSafeParser[IN](
|
|||
Iterator.empty
|
||||
case FailFastMode =>
|
||||
throw new SparkException("Malformed records are detected in record parsing. " +
|
||||
s"Parse Mode: ${FailFastMode.name}.", e.cause)
|
||||
s"Parse Mode: ${FailFastMode.name}. To process malformed records as null " +
|
||||
"result, try setting the option 'mode' as 'PERMISSIVE'.", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue