stoty commented on a change in pull request #150:
URL: https://github.com/apache/calcite-avatica/pull/150#discussion_r697160600



##########
File path: 
core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
##########
@@ -722,13 +701,21 @@ protected Number getNumber() throws SQLException {
       return (Number) super.getObject();
     }
 
+    //FIXME There are several problems with this, the code below simply 
implements
+    //a previous behaviour codified by the Calcite test suite.
+    //
+    // 1. It interprets a scale of 0 as a NOOP parameter, it should in fact 
drop all fractionals
+    // 2. It uses RoundingMode.UNNECESSARY. All other Accessors use 
RoundingMode.DOWN, and
+    //    there is nothing in the specs that suggests that it should behave 
differently
+    // 3. The scale from MetaData is NOT applied to BigDecimal values. Why ?
+    // 4. Metadata scale is only applied for getBigDecimal(), and only in this 
Accessor. Why ?
     public BigDecimal getBigDecimal(int scale) throws SQLException {
       Number n = getNumber();
       if (n == null) {
         return null;
       }
       BigDecimal decimal = AvaticaSite.toBigDecimal(n);
-      if (0 != scale) {
+      if (0 != scale && !(n instanceof BigDecimal)) {

Review comment:
       Most of the relevant tests are actually in Calcite, but luckily the 
Apache CI runs the calcite tests with the change as well. I couldn't get the 
_localAvatica_ calcite option to work (probably my mistake), but the following 
does work:
   - change the avatica version in calcite to snapshot (which BTW wasn't 
updated to 1.19 yet)
   - build avatica with `./gradlew publishToMavenLocal`
   - build calcite with `./gradlew test  -PenableMavenLocal=true`
   




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