julianhyde commented on a change in pull request #1834: [CALCITE-3823] Do not
use String.replaceAll
URL: https://github.com/apache/calcite/pull/1834#discussion_r385465537
##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -1694,16 +1696,18 @@ public static String toString(double x) {
BigDecimal bigDecimal =
new BigDecimal(x, MathContext.DECIMAL64).stripTrailingZeros();
final String s = bigDecimal.toString();
- return s.replaceAll("0*E", "E").replace("E+", "E");
+ return PATTERN_0_STAR_E.matcher(s).replaceAll("E").replace("E+", "E");
}
/** CAST(DECIMAL AS VARCHAR). */
public static String toString(BigDecimal x) {
final String s = x.toString();
- if (s.startsWith("0")) {
+ if (s.equals("0")) {
+ return s;
+ } else if (s.startsWith("0.")) {
Review comment:
The `Float.toString()`is not locale-dependent - that is, it always uses '.'
as decimal separator - and I think that's what we want for `CAST(REAL AS
VARCHAR)`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services