leaves12138 commented on code in PR #1118:
URL: https://github.com/apache/paimon-rust/pull/1118#discussion_r4254999608


##########
crates/paimon/src/common/number.rs:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Java numeric text shared by partition paths and value conversions.
+
+/// Java's shortest-decimal string contract (JDK 19+), including its notation
+/// thresholds and closest choice among one- and two-digit decimals. Rust's
+/// shortest Display chooses different digits at ties; Ryƫ uses ties-to-even.
+pub(crate) fn format_java_float<T: ryu::Float + std::fmt::LowerExp + Copy + 
Into<f64>>(

Review Comment:
   `format_java_float` implements the JDK 19+ shortest-decimal algorithm, but 
the corresponding Java cast path uses `BigDecimal.valueOf(double)` on the 
supported runtime JVMs (this project still targets Java 8 and CI covers Java 
8/11/17). These runtimes do not always produce the same text as JDK 19+. For 
example, for the double bits `0xc381e88f38c0c8fd`, JDK 8/11/17 produce 
`-1.61304845894623136E17`, while this function produces 
`-1.6130484589462314E17` (the JDK 21 result). At `DECIMAL(38,20)`, the Java 
value is `-161304845894623136.00000000000000000000`, but this Rust path 
produces `-161304845894623140.00000000000000000000`. Because this text is fed 
into decimal conversion, this is a data-compatibility issue rather than a 
formatting-only difference. Please use an algorithm matching the JVM versions 
Paimon supports, or explicitly align the Java compatibility target before 
merging.



-- 
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]

Reply via email to