You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/12/12 11:30:03 UTC

[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #3916: [KYUUBI #3915] Client support detecting ResultSet codec

pan3793 commented on code in PR #3916:
URL: https://github.com/apache/incubator-kyuubi/pull/3916#discussion_r1045709884


##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -743,4 +763,57 @@ public String getQueryId() throws SQLException {
   public void setInPlaceUpdateStream(InPlaceUpdateStream stream) {
     this.inPlaceUpdateStream = stream;
   }
+
+  private TGetResultSetMetadataResp getResultSetMetadata() throws SQLException {
+    try {
+      TGetResultSetMetadataReq metadataReq = new TGetResultSetMetadataReq(stmtHandle);
+      // TODO need session handle
+      TGetResultSetMetadataResp metadataResp;
+      metadataResp = client.GetResultSetMetadata(metadataReq);
+      Utils.verifySuccess(metadataResp.getStatus());
+      return metadataResp;
+    } catch (SQLException eS) {
+      throw eS; // rethrow the SQLException as is
+    } catch (Exception ex) {
+      throw new KyuubiSQLException("Could not create ResultSet: " + ex.getMessage(), ex);
+    }
+  }
+
+  private void parseMetadata(
+      TGetResultSetMetadataResp metadataResp,
+      List<String> columnNames,
+      List<TTypeId> columnTypes,
+      List<JdbcColumnAttributes> columnAttributes)
+      throws KyuubiSQLException {
+    TTableSchema schema = metadataResp.getSchema();
+    if (schema == null || !schema.isSetColumns()) {
+      throw new KyuubiSQLException("the result set schema is null");
+    }
+
+    // parse kyuubi hint
+    List<String> infoMessages = metadataResp.getStatus().getInfoMessages();
+    if (infoMessages != null) {
+      metadataResp
+          .getStatus()
+          .getInfoMessages()
+          .forEach(
+              line -> {
+                String[] keyValue = line.split("=");
+                String key = keyValue[0];
+                String value = keyValue[1];

Review Comment:
   will cause NPE if server return some message does not contains '='



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org