sandip-db commented on code in PR #52801:
URL: https://github.com/apache/spark/pull/52801#discussion_r2479854245
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/StaxXmlParser.scala:
##########
@@ -1278,18 +1278,19 @@ object StaxXmlParser {
// Try parsing the value as decimal
val decimalParser = ExprUtils.getDecimalParser(options.locale)
Review Comment:
Unrelated to the issue at hand, `decimalParser` should be reused rather than
initializing for every value.
Can the caller pass it instead?
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/StaxXmlParser.scala:
##########
@@ -1278,18 +1278,19 @@ object StaxXmlParser {
// Try parsing the value as decimal
val decimalParser = ExprUtils.getDecimalParser(options.locale)
- allCatch opt decimalParser(value) match {
- case Some(decimalValue) =>
- var d = decimalValue
- if (d.scale() < 0) {
- d = d.setScale(0)
- }
- if (d.scale <= VariantUtil.MAX_DECIMAL16_PRECISION &&
- d.precision <= VariantUtil.MAX_DECIMAL16_PRECISION) {
- builder.appendDecimal(d)
- return
- }
- case _ =>
+ try {
+ var d = decimalParser(value)
+ if (d.scale() < 0) {
+ d = d.setScale(0)
+ }
+ if (d.scale <= VariantUtil.MAX_DECIMAL16_PRECISION &&
+ d.precision <= VariantUtil.MAX_DECIMAL16_PRECISION) {
+ builder.appendDecimal(d)
+ return
+ }
+ } catch {
+ case NonFatal(_) =>
+ // Ignore the exception and parse it as a string later
Review Comment:
nit:
```suggestion
// Ignore the exception and parse it as a string below
```
--
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]