cloud-fan commented on a change in pull request #35060:
URL: https://github.com/apache/spark/pull/35060#discussion_r781172352
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/NumberUtils.scala
##########
@@ -21,49 +21,73 @@ import java.math.BigDecimal
import java.text.{DecimalFormat, NumberFormat, ParsePosition}
import java.util.Locale
+import org.apache.spark.sql.AnalysisException
+import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.errors.{QueryCompilationErrors,
QueryExecutionErrors}
import org.apache.spark.sql.types.Decimal
import org.apache.spark.unsafe.types.UTF8String
object NumberUtils {
- private val pointSign = '.'
- private val letterPointSign = 'D'
- private val commaSign = ','
- private val letterCommaSign = 'G'
- private val minusSign = '-'
- private val letterMinusSign = 'S'
- private val dollarSign = '$'
+ private final val POINT_SIGN = '.'
+ private final val POINT_LETTER = 'D'
+ private final val COMMA_SIGN = ','
+ private final val COMMA_LETTER = 'G'
+ private final val MINUS_SIGN = '-'
+ private final val MINUS_LETTER = 'S'
+ private final val DOLLAR_SIGN = '$'
+ private final val NINE_DIGIT = '9'
+ private final val ZERO_DIGIT = '0'
+ private final val POUND_SIGN = '#'
- private val commaSignStr = commaSign.toString
+ private final val COMMA_SIGN_STRING = COMMA_SIGN.toString
+ private final val POUND_SIGN_STRING = POUND_SIGN.toString
+ private final val SIGN_SET = Set(POINT_SIGN, COMMA_SIGN, MINUS_SIGN,
DOLLAR_SIGN)
+
+ /**
+ * DecimalFormat provides '#' and '0' as placeholder of digit, ',' as
grouping separator,
+ * '.' as decimal separator, '-' as minus, '$' as dollar, but '9', 'G', 'D',
'S'. So we need
+ * replace them show below:
+ * 1. '9' -> '#'
+ * 2. 'G' -> ','
+ * 3. 'D' -> '.'
+ * 4. 'S' -> '-'
+ *
+ * Note: When calling format, we must preserve the digits after decimal
point, so the digits
Review comment:
I'm not very sure about this behavior, but let's leave the discussion
when adding `to_char`
--
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]