sandip-db commented on code in PR #52801:
URL: https://github.com/apache/spark/pull/52801#discussion_r2479842978
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/StaxXmlParser.scala:
##########
@@ -1278,18 +1278,24 @@ 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 &&
+ try {
+ allCatch opt decimalParser(value) match {
+ case Some(decimalValue) =>
+ var d = decimalValue
Review Comment:
```suggestion
try {
var d = decimalParser(value)
```
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/StaxXmlParser.scala:
##########
@@ -1278,18 +1278,24 @@ 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 &&
+ try {
+ 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 _ =>
+ builder.appendDecimal(d)
+ return
+ }
+ case _ =>
+ }
+ } catch {
+ case NonFatal(e) =>
+ // Ignore the exception and parse it as a string later
+ logWarning("Failed to parse XML character as decimal.", e)
Review Comment:
Logging not required.. as most strings will fail decimal parsing.
--
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]