shujingyang-db commented on code in PR #44875:
URL: https://github.com/apache/spark/pull/44875#discussion_r1465755400
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/StaxXmlParser.scala:
##########
@@ -280,20 +267,45 @@ class StaxXmlParser(
while (!shouldStop) {
parser.nextEvent match {
case e: StartElement =>
- kvPairs +=
-
(UTF8String.fromString(StaxXmlParserUtils.getName(e.asStartElement.getName,
options)) ->
- convertField(parser, valueType))
+ val key = UTF8String.fromString(
+ StaxXmlParserUtils.getName(e.asStartElement.getName, options))
+ try {
+ kvPairs += key -> convertField(parser, valueType)
+ } catch {
+ case partialValueException: PartialValueException =>
+ badRecordException =
badRecordException.orElse(Some(partialValueException.cause))
+ StaxXmlParserUtils.skipChildren(parser)
+ kvPairs += key -> partialValueException.partialResult
+ case NonFatal(e) =>
+ badRecordException = badRecordException.orElse(Some(e))
+ StaxXmlParserUtils.skipChildren(parser)
+ }
case c: Characters if !c.isWhiteSpace =>
// Create a value tag field for it
- kvPairs +=
+ val key = UTF8String.fromString(options.valueTag)
// TODO: We don't support an array value tags in map yet.
- (UTF8String.fromString(options.valueTag) -> convertTo(c.getData,
valueType))
+ try {
+ kvPairs += (key -> convertTo(c.getData, valueType))
+ } catch {
+ case partialValueException: PartialValueException =>
+ badRecordException =
badRecordException.orElse(Some(partialValueException.cause))
+ StaxXmlParserUtils.skipChildren(parser)
+ kvPairs += key -> partialValueException.partialResult
+ case NonFatal(e) =>
+ badRecordException = badRecordException.orElse(Some(e))
+ StaxXmlParserUtils.skipChildren(parser)
Review Comment:
It will not. This is the exception branch.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]