You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/02/16 09:00:40 UTC

[GitHub] [incubator-pinot] fx19880617 commented on a change in pull request #6581: Add support for getObject to Pinot JDBC driver

fx19880617 commented on a change in pull request #6581:
URL: https://github.com/apache/incubator-pinot/pull/6581#discussion_r576652602



##########
File path: pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/PinotResultSet.java
##########
@@ -297,6 +299,54 @@ public String getString(int columnIndex)
     return val;
   }
 
+  @Override
+  public Object getObject(int columnIndex)
+      throws SQLException {
+
+    String dataType = _columnDataTypes.getOrDefault(columnIndex, "");
+
+    if (dataType.isEmpty()) {
+      throw new SQLDataException("Data type not supported for " + dataType);
+    }
+
+    switch (dataType) {
+      case "STRING":
+        return getString(columnIndex);
+      case "INT":
+        return getInt(columnIndex);
+      case "LONG":
+        return getLong(columnIndex);
+      case "FLOAT":
+        return getFloat(columnIndex);
+      case "DOUBLE":
+        return getDouble(columnIndex);
+      case "BOOLEAN":
+        return getBoolean(columnIndex);
+      case "BYTES":
+        return getBytes(columnIndex);
+      default:
+        throw new SQLDataException("Data type not supported for " + dataType);
+    }
+  }
+
+  @Override
+  public <T> T getObject(int columnIndex, Class<T> type)

Review comment:
       Can you write a test for this?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org