github-actions[bot] commented on code in PR #65609:
URL: https://github.com/apache/doris/pull/65609#discussion_r3668298379
##########
regression-test/suites/external_table_p0/tvf/test_hdfs_parquet_group6.groovy:
##########
@@ -726,15 +726,15 @@ suite("test_hdfs_parquet_group6", "p0,external") {
uri = "${defaultFS}" +
"/user/doris/tvf_data/test_hdfs_parquet/group6/fixed_len_byte_array.parquet"
- order_qt_test_98 """ select * from HDFS(
+ order_qt_test_98 """ select /*+
SET_VAR(enable_file_scanner_v2=false) */ * from HDFS(
Review Comment:
Please preserve FileScannerV2 coverage for this asset. V2 is enabled by
default (and fuzzy external sessions intentionally randomize it), but this
patch pins both `fixed_len_byte_array.parquet` queries—this decimal/text case
and the `enable_mapping_varbinary=true` case below—to V1. An exact suite search
finds no other end-to-end query for this fixture, so the production-default
scanner and its UUID-to-VARBINARY mapping are no longer exercised. Keep/add
matching V2 cases, or expose and fix the V2 incompatibility if that is why
these unrelated hints were added.
##########
fe/fe-common/src/main/java/org/apache/doris/common/FractionalFormat.java:
##########
@@ -26,42 +27,80 @@
public class FractionalFormat {
/**
- * Get string of double/float value for cast to string and output to mysql.
+ * Get the shortest string that round-trips to the given float value.
*
- * @param value The double/float value.
- * @param precision precision
- * @param sciFormat format for string with scientific form.
+ * @param value The float value.
* @return string value.
*/
- public static String getFormatStringValue(double value, int precision,
String sciFormat) {
+ public static String getFormatStringValue(float value) {
+ if (Float.isNaN(value)) {
+ return "NaN";
+ }
+ if (Float.isInfinite(value)) {
+ return value > 0 ? "Infinity" : "-Infinity";
+ }
+ if (value == 0) {
+ return Float.floatToRawIntBits(value) < 0 ? "-0" : "0";
+ }
+ BigDecimal exactValue = new BigDecimal(value);
+ int bits = Float.floatToRawIntBits(value);
+ for (int precision = 1; precision < 9; precision++) {
+ BigDecimal candidate = exactValue.round(new MathContext(precision,
RoundingMode.HALF_EVEN));
+ if
(Float.floatToRawIntBits(Float.parseFloat(candidate.toString())) == bits) {
+ return format(candidate);
+ }
+ }
+ return format(exactValue.round(new MathContext(9,
RoundingMode.HALF_EVEN)));
+ }
+
+ /**
+ * Get the shortest string that round-trips to the given double value.
+ *
+ * @param value The double value.
+ * @return string value.
+ */
+ public static String getFormatStringValue(double value) {
if (Double.isNaN(value)) {
return "NaN";
}
if (Double.isInfinite(value)) {
return value > 0 ? "Infinity" : "-Infinity";
}
- if (Double.compare(value, 0.0) == 0) {
- return "0";
- }
- if (Double.compare(value, -0.0) == 0) {
- return "-0";
+ if (value == 0) {
+ return Double.doubleToRawLongBits(value) < 0 ? "-0" : "0";
}
- int expLower = -4;
- int exponent = (int) Math.floor(Math.log10(Math.abs(value)));
- if (exponent < precision && exponent >= expLower) {
- BigDecimal bd = new BigDecimal(value);
- bd = bd.setScale(precision - bd.precision() + bd.scale(),
RoundingMode.HALF_UP);
- String result = bd.toPlainString();
- if (result.contains(".")) {
- result = result.replaceAll("0+$", "");
- if (result.endsWith(".")) {
- result = result.substring(0, result.length() - 1);
- }
+ BigDecimal exactValue = new BigDecimal(value);
+ long bits = Double.doubleToRawLongBits(value);
+ for (int precision = 1; precision < 17; precision++) {
+ BigDecimal candidate = exactValue.round(new MathContext(precision,
RoundingMode.HALF_EVEN));
Review Comment:
The precision search can miss the shortest round-tripping decimal because it
tests only the nearest `HALF_EVEN` rounding of the exact value. For example,
`Math.scalb(1.0, -24)` reaches the fallback and returns
`5.9604644775390625e-08`, but the adjacent 16-digit value
`5.960464477539063e-08` parses to the same raw bits (and a shortest-decimal
converter selects it). FLOAT has the same issue at `Math.scalb(1.0f, -96)`,
where this emits nine digits instead of eight. This makes FE folding
non-shortest and can disagree with the BE formatter even without a rolling
upgrade. Please use a proven shortest-round-trip conversion or check the
neighboring candidates, and add both boundary cases to the FE/BE parity
regression.
--
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]