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



##########
File path: 
server/src/test/java/org/apache/calcite/avatica/remote/RemoteMetaTest.java
##########
@@ -481,6 +483,38 @@ private static String longString(String fragment, int 
length) {
     }
   }
 
+  @Test public void testBigDecimalTest() throws Exception {
+    final String tableName = "testbigdecimal";
+    try (Connection conn = DriverManager.getConnection(url);
+          Statement stmt = conn.createStatement()) {
+      conn.setAutoCommit(false);
+      stmt.execute("DROP TABLE IF EXISTS " + tableName);
+      stmt.execute("CREATE TABLE " + tableName + " ("
+          + "pk VARCHAR NOT NULL PRIMARY KEY, "
+          + "v1 DECIMAL(10,5))");
+      conn.commit();
+      try (PreparedStatement pstmt = conn.prepareStatement("INSERT INTO "
+          + tableName + " values(?, ?)")) {
+        pstmt.setString(1, "1");
+        pstmt.setBigDecimal(2, new BigDecimal("12345.67890"));
+        assertEquals(1, pstmt.executeUpdate());
+
+        pstmt.setString(1, "2");
+        pstmt.setObject(2, new BigDecimal("12345.67890"));
+        assertEquals(1, pstmt.executeUpdate());
+
+        pstmt.setString(1, "3");
+        pstmt.setObject(2, new BigDecimal("12345.67890"), Types.NUMERIC);
+        assertEquals(1, pstmt.executeUpdate());
+
+        pstmt.setString(1, "4");
+        pstmt.setObject(2, new BigDecimal("12345.67890"), Types.DECIMAL);
+        assertEquals(1, pstmt.executeUpdate());
+      }
+      conn.commit();

Review comment:
       Wouldn't be a bad idea to validate that we can pull the value back out 
as a BigDecimal too (if I messed up BigDecimal on the write path, wouldn't be 
surprised if I also did on the read path :P).

##########
File path: core/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java
##########
@@ -360,6 +361,8 @@ public ColumnMetaData setRep(Rep rep) {
         builder.put(rep.clazz, rep);
       }
       builder.put(byte[].class, BYTE_STRING);
+      //The lookup code is not smart enough to handle subclasses
+      builder.put(BigDecimal.class, NUMBER);

Review comment:
       Any reason to not put this as a value for the `Rep` enum? 




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