Skip to content

Commit

Permalink
edp963#2207, support Hive connection
Browse files Browse the repository at this point in the history
  • Loading branch information
chenl committed Jun 3, 2021
1 parent e88f8e7 commit 6effeed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions server/src/main/java/edp/core/enums/DataTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public enum DataTypeEnum {

MYSQL("mysql", "mysql", "com.mysql.cj.jdbc.Driver", "`", "`", "'", "'"),

HIVE2("hive2", "hive", "org.apache.hive.jdbc.HiveDriver", "`", "`", "`", "`"),

ORACLE("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),

SQLSERVER("sqlserver", "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
Expand Down
18 changes: 14 additions & 4 deletions server/src/main/java/edp/core/utils/SqlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,15 @@ public List<String> getDatabases() throws SourceException {
dbList.add(catalog);
} else {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet rs = metaData.getCatalogs();
while (rs.next()) {
dbList.add(rs.getString(1));
ResultSet rs = null;
if (dataTypeEnum == HIVE2)
rs = metaData.getSchemas();
else
rs = metaData.getCatalogs();
if (rs != null) {
while (rs.next()) {
dbList.add(rs.getString(1));
}
}
}

Expand Down Expand Up @@ -478,7 +484,10 @@ public List<QueryColumn> getTableList(String dbName) throws SourceException {
DatabaseMetaData metaData = connection.getMetaData();
String schema = null;
try {
schema = metaData.getConnection().getSchema();
if (dataTypeEnum == HIVE2)
schema = dbName;
else
schema = metaData.getConnection().getSchema();
} catch (Throwable t) {
// ignore
}
Expand Down Expand Up @@ -527,6 +536,7 @@ private String getDBSchemaPattern(String schema) {
schemaPattern = "dbo";
break;
case CLICKHOUSE:
case HIVE2:
case PRESTO:
if (!StringUtils.isEmpty(schema)) {
schemaPattern = schema;
Expand Down

0 comments on commit 6effeed

Please sign in to comment.