Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ODPS dbType #2283

Open
wants to merge 1 commit into
base: dev-0.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions server/src/main/java/edp/core/common/jdbc/JdbcDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,7 @@ public DruidDataSource getDataSource(JdbcSourceInfo jdbcSourceInfo) throws Sourc
}

// druid wall filter not support some database so set type mysql
if (DataTypeEnum.MOONBOX == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.MONGODB == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.ELASTICSEARCH == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.CASSANDRA == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.VERTICA == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.KYLIN == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.HANA == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.IMPALA == DataTypeEnum.urlOf(jdbcUrl) ||
DataTypeEnum.TDENGINE == DataTypeEnum.urlOf(jdbcUrl)) {
if (DataTypeEnum.hasMysqlFeature(jdbcUrl)) {
wallFilter.setDbType(DataTypeEnum.MYSQL.getFeature());
}

Expand Down
18 changes: 17 additions & 1 deletion server/src/main/java/edp/core/enums/DataTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import edp.core.consts.Consts;
import edp.core.exception.SourceException;

import java.util.EnumSet;
import java.util.Set;

public enum DataTypeEnum {

MYSQL("mysql", "mysql", "com.mysql.cj.jdbc.Driver", "`", "`", "'", "'"),
Expand Down Expand Up @@ -56,7 +59,9 @@ public enum DataTypeEnum {

IMPALA("impala", "impala", "com.cloudera.impala.jdbc41.Driver", "", "", "'", "'"),

TDENGINE("TAOS", "TAOS", "com.taosdata.jdbc.TSDBDriver", "'", "'", "\"", "\"");
TDENGINE("TAOS", "TAOS", "com.taosdata.jdbc.TSDBDriver", "'", "'", "\"", "\""),

ODPS("odps", "odps", "com.aliyun.odps.jdbc.OdpsDriver", "", "", "`", "`");

private String feature;
private String desc;
Expand All @@ -76,6 +81,9 @@ public enum DataTypeEnum {
this.aliasSuffix = aliasSuffix;
}

private static Set<DataTypeEnum> mysqlTypeDBs = EnumSet.of(MOONBOX, MONGODB, ELASTICSEARCH,
CASSANDRA, VERTICA, KYLIN, HANA, IMPALA, TDENGINE, ODPS);

public static DataTypeEnum urlOf(String jdbcUrl) throws SourceException {
String url = jdbcUrl.toLowerCase().trim();
for (DataTypeEnum dataTypeEnum : values()) {
Expand All @@ -86,6 +94,14 @@ public static DataTypeEnum urlOf(String jdbcUrl) throws SourceException {
return null;
}

public static boolean hasMysqlFeature(String jdbcUrl) throws SourceException {
DataTypeEnum dataTypeEnum = urlOf(jdbcUrl);
if (dataTypeEnum != null && mysqlTypeDBs.contains(dataTypeEnum)) {
return true;
}
return false;
}

public String getFeature() {
return feature;
}
Expand Down