This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 2330b4b925d [hotfix](jdbc catalog) fix jdbcmysqlclient npe (#28022)
2330b4b925d is described below

commit 2330b4b925d6c95d77ed48a2a78aa41e00838392
Author: zy-kkk <[email protected]>
AuthorDate: Thu Dec 7 10:57:04 2023 +0800

    [hotfix](jdbc catalog) fix jdbcmysqlclient npe (#28022)
---
 .../doris/datasource/jdbc/client/JdbcMySQLClient.java    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
index 61ba2a0db47..c8506cc99a9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
@@ -119,15 +119,19 @@ public class JdbcMySQLClient extends JdbcClient {
         List<JdbcFieldSchema> tableSchema = 
com.google.common.collect.Lists.newArrayList();
         // if isLowerCaseTableNames == true, tableName is lower case
         // but databaseMetaData.getColumns() is case sensitive
+        String currentDbName = dbName;
+        String currentTableName = tableName;
         if (isLowerCaseTableNames) {
-            dbName = lowerDBToRealDB.get(dbName);
-            tableName = lowerTableToRealTable.get(tableName);
+            currentDbName = getRealDatabaseName(dbName);
+            currentTableName = getRealTableName(dbName, tableName);
         }
+        String finalDbName = currentDbName;
+        String finalTableName = currentTableName;
         try {
             DatabaseMetaData databaseMetaData = conn.getMetaData();
             String catalogName = getCatalogName(conn);
-            rs = getColumns(databaseMetaData, catalogName, dbName, tableName);
-            List<String> primaryKeys = getPrimaryKeys(databaseMetaData, 
catalogName, dbName, tableName);
+            rs = getColumns(databaseMetaData, catalogName, finalDbName, 
finalTableName);
+            List<String> primaryKeys = getPrimaryKeys(databaseMetaData, 
catalogName, finalDbName, finalTableName);
             Map<String, String> mapFieldtoType = null;
             while (rs.next()) {
                 JdbcFieldSchema field = new JdbcFieldSchema();
@@ -140,7 +144,7 @@ public class JdbcMySQLClient extends JdbcClient {
                 // in mysql-jdbc-connector-5.1.*, TYPE_NAME of BITMAP column 
in doris will be "BITMAP"
                 field.setDataTypeName(rs.getString("TYPE_NAME"));
                 if (isDoris) {
-                    mapFieldtoType = getColumnsDataTypeUseQuery(dbName, 
tableName);
+                    mapFieldtoType = getColumnsDataTypeUseQuery(finalDbName, 
finalTableName);
                     
field.setDataTypeName(mapFieldtoType.get(rs.getString("COLUMN_NAME")));
                 }
                 field.setKey(primaryKeys.contains(field.getColumnName()));
@@ -162,7 +166,7 @@ public class JdbcMySQLClient extends JdbcClient {
                 tableSchema.add(field);
             }
         } catch (SQLException e) {
-            throw new JdbcClientException("failed to get table name list from 
jdbc for table %s:%s", e, tableName,
+            throw new JdbcClientException("failed to get table name list from 
jdbc for table %s:%s", e, finalTableName,
                 Util.getRootCauseMessage(e));
         } finally {
             close(rs, conn);


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

Reply via email to