dengzhhu653 commented on code in PR #4475:
URL: https://github.com/apache/hive/pull/4475#discussion_r1268984558


##########
jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/HiveDatabaseAccessor.java:
##########
@@ -56,4 +57,19 @@ protected String addLimitToQuery(String sql, int limit) {
     }
     return sql + " LIMIT " + limit;
   }
+
+  @Override
+  protected List<String> getColNamesFromRS(ResultSet rs) throws Exception {
+    List<String> columnNames = super.getColNamesFromRS(rs);
+    return columnNames.stream()
+        .map(c -> {
+          int lastIndex = c.lastIndexOf(".");
+          return lastIndex == -1 ? c : c.substring(lastIndex + 1); })
+        .collect(Collectors.toList());
+  }
+
+  @Override
+  protected String getMetaDataQuery(String sql) {
+    return addLimitToQuery(sql, 0);

Review Comment:
   This is where the method `getMetaDataQuery` takes place:
   
https://github.com/apache/hive/blob/master/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/GenericJdbcDatabaseAccessor.java#L74-L109
   `GenericJdbcDatabaseAccessor` is the parent class of all jdbc sources. In 
this example, `HiveDatabaseAccessor` is a child of 
`GenericJdbcDatabaseAccessor` and override some methods the 
`GenericJdbcDatabaseAccessor` provided, `getMetaDataQuery` is one of the such 
method.
   
   I'm not sure how to add `addLimitToQuery(sql, 0)` directly unless we change 
this line:
   
https://github.com/apache/hive/blob/master/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/GenericJdbcDatabaseAccessor.java#L86
   but we couldn't assume the sql after `addLimitToQuery(sql, 0)` would return 
the correct column metadata on different kinds of sources.
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to