Merge pull request #5626 from dataease/pr@dev@fixdatasource

fix: impala 过滤时间出错
This commit is contained in:
taojinlong 2023-07-11 16:16:22 +08:00 committed by GitHub
commit de1c1edff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -781,7 +781,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
case StarRocks:
MysqlConfiguration mysqlConfiguration = new Gson().fromJson(datasource.getConfiguration(), MysqlConfiguration.class);
mysqlConfiguration.getJdbc();
if(!mysqlConfiguration.getDataBase().matches("^[0-9a-zA-Z_-]{1,}$")){
if(!mysqlConfiguration.getDataBase().matches("^[0-9a-zA-Z_.-]{1,}$")){
throw new Exception("Invalid database name");
}
break;
@ -796,7 +796,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
break;
case sqlServer:
SqlServerConfiguration sqlServerConfiguration = new Gson().fromJson(datasource.getConfiguration(), SqlServerConfiguration.class);
if(!sqlServerConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){
if(!sqlServerConfiguration.getDataBase().matches("^[0-9a-zA-Z_-]{1,}$")){
throw new Exception("Invalid database name");
}
break;

View File

@ -1095,7 +1095,10 @@ public class ImpalaQueryProvider extends QueryProvider {
whereName = "upper(" + whereName + ")";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(request.getDatasetTableField().getDeExtractType() == DeTypeConstants.DE_TIME){
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
whereValue = String.format(ImpalaConstants.WHERE_BETWEEN, startTime, endTime);