amaliujia commented on a change in pull request #35269:
URL: https://github.com/apache/spark/pull/35269#discussion_r828446812
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/NumberFormatter.scala
##########
@@ -98,27 +100,28 @@ class NumberFormatter(originNumberFormat: String, isParse:
Boolean = true) exten
case MINUS_LETTER => MINUS_SIGN
case other => other
}
- // If the comma is at the beginning or end of number format, then
DecimalFormat will be
- // invalid. For example, "##,###," or ",###,###" for DecimalFormat is
invalid, so we must use
- // "##,###" or "###,###".
-
normalizedFormat.stripPrefix(COMMA_SIGN_STRING).stripSuffix(COMMA_SIGN_STRING)
+ normalizedFormat
}
- private def isSign(c: Char): Boolean = {
- SIGN_SET.contains(c)
- }
+ private def isSign(c: Char): Boolean = SIGN_SET.contains(c)
private def transform(format: String): String = {
- if (format.contains(MINUS_SIGN)) {
+ // If the comma is at the beginning or end of number format, then
DecimalFormat will be
+ // invalid. For example, "##,###," or ",###,###" for DecimalFormat is
invalid, so we must use
+ // "##,###" or "###,###".
+ val stripedString =
format.stripPrefix(COMMA_SIGN_STRING).stripSuffix(COMMA_SIGN_STRING)
+ if (stripedString.contains(MINUS_SIGN)) {
// For example: '#.######' represents a positive number,
// but '#.######;#.######-' represents a negative number.
- val positiveFormatString = format.replaceAll("-", "")
- s"$positiveFormatString;$format"
+ val positiveFormatString = stripedString.replaceAll("-", "")
+ s"$positiveFormatString;$stripedString"
} else {
- format
+ stripedString
}
}
+ private def isDigitPosition(c: Char): Boolean = c == ZERO_DIGIT || c ==
POUND_SIGN
Review comment:
nit:
`private def isDigitPosition(c: Char): Boolean = (c == ZERO_DIGIT || c ==
POUND_SIGN)`
--
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]