scruz-denodo commented on code in PR #1407:
URL: https://github.com/apache/arrow-java/pull/1407#discussion_r4739186939


##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/accessor/impl/numeric/ArrowFlightJdbcFloat4VectorAccessorTest.java:
##########
@@ -179,7 +179,80 @@ public void testShouldGetDoubleMethodFromFloat4Vector() 
throws Exception {
     accessorIterator.assertAccessorGetter(
         vector,
         ArrowFlightJdbcFloat4VectorAccessor::getDouble,
-        accessor -> is((double) accessor.getFloat()));
+        accessor -> 
is(Double.parseDouble(Float.toString(accessor.getFloat()))));
+  }
+
+  @Test
+  public void testShouldGetDoubleThatRoundTripsToTheSameFloat() throws 
Exception {
+    accessorIterator.iterate(
+        vector,
+        (accessor, currentRow) ->
+            assertThat((float) accessor.getDouble(), is(accessor.getFloat())));
+  }
+
+  @Test
+  public void testShouldGetDecimalValuesWithoutFloatWideningArtifacts() throws 
Exception {
+    final float[] values = {0.1f, -0.1f, 0.2f, 0.3f, 1.1f, 123.456f, 3.4e-5f, 
-0.0f};
+    try (final Float4Vector float4Vector =
+        new Float4Vector("ID", rootAllocatorTestExtension.getRootAllocator())) 
{
+      for (int i = 0; i < values.length; i++) {
+        float4Vector.setSafe(i, values[i]);
+      }
+      float4Vector.setValueCount(values.length);
+
+      accessorIterator.iterate(
+          float4Vector,
+          (accessor, currentRow) -> {
+            final String expected = Float.toString(values[currentRow]);

Review Comment:
   Added changes.



##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/numeric/ArrowFlightJdbcFloat4VectorAccessor.java:
##########
@@ -110,7 +110,7 @@ public BigDecimal getBigDecimal() throws SQLException {
       throw new SQLException("BigDecimal doesn't support Infinite/NaN.");
     }
 
-    return this.wasNull ? null : BigDecimal.valueOf(value);
+    return this.wasNull ? null : new BigDecimal(Float.toString(value));

Review Comment:
   Added changes. Not sure if it is required to add the `breaking-change` label 
for the `getBigDecimal` method



##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/numeric/ArrowFlightJdbcFloat4VectorAccessor.java:
##########
@@ -99,7 +99,7 @@ public float getFloat() {
 
   @Override
   public double getDouble() {
-    return this.getFloat();
+    return Double.parseDouble(Float.toString(this.getFloat()));

Review Comment:
   Added changes.



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