Merge pull request #5299 from dataease/pr@dev@fixdataset

fix: 时间联动不生效
This commit is contained in:
taojinlong 2023-05-24 17:14:49 +08:00 committed by GitHub
commit 21038df9f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 115 additions and 44 deletions

View File

@ -1122,19 +1122,32 @@ public class Db2QueryProvider extends QueryProvider {
} else {
originName = String.format(Db2Constants.STR_TO_DATE, originName);
}
whereName = String.format(Db2Constants.DATE_FORMAT, originName, format);
if(request.getOperator().equals("between")){
whereName = originName;
}else {
whereName = String.format(Db2Constants.DATE_FORMAT, originName, format);
}
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_INT_FORMAT);
whereName = String.format(Db2Constants.FROM_UNIXTIME, cast, format);
if(request.getOperator().equals("between")){
String cast = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_INT_FORMAT);
whereName = String.format(Db2Constants.FROM_UNIXTIME, cast, Db2Constants.DEFAULT_DATE_FORMAT);
}else {
String cast = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_INT_FORMAT);
whereName = String.format(Db2Constants.FROM_UNIXTIME, cast, format);
}
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
if (field.getType().equalsIgnoreCase("TIME")) {
whereName = String.format(Db2Constants.FORMAT_TIME, originName, format);
} else if (field.getType().equalsIgnoreCase("DATE")) {
whereName = String.format(Db2Constants.FORMAT_DATE, originName, format);
} else {
if(request.getOperator().equals("between")){
whereName = originName;
}else {
if (field.getType().equalsIgnoreCase("TIME")) {
whereName = String.format(Db2Constants.FORMAT_TIME, originName, format);
} else if (field.getType().equalsIgnoreCase("DATE")) {
whereName = String.format(Db2Constants.FORMAT_DATE, originName, format);
} else {
whereName = originName;
}
}
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {

View File

@ -1038,14 +1038,31 @@ public class HiveQueryProvider extends QueryProvider {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(HiveConstants.DATE_FORMAT, originName, format);
String date = String.format(HiveConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : HiveConstants.DEFAULT_DATE_FORMAT);
if(request.getOperator().equals("between")){
whereName = date;
}else {
whereName = String.format(HiveConstants.DATE_FORMAT, date, format);
}
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if(request.getOperator().equals("between")){
String cast = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(HiveConstants.FROM_UNIXTIME, cast, HiveConstants.DEFAULT_DATE_FORMAT);
}else {
String cast = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(HiveConstants.FROM_UNIXTIME, cast, format);
}
String cast = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(HiveConstants.FROM_UNIXTIME, cast, format);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = String.format(HiveConstants.DATE_FORMAT, originName, format);
if(request.getOperator().equals("between")){
whereName = originName;
}else {
whereName = String.format(HiveConstants.DATE_FORMAT, originName, format);
}
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {

View File

@ -1035,14 +1035,27 @@ public class ImpalaQueryProvider extends QueryProvider {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(ImpalaConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : ImpalaConstants.DEFAULT_DATE_FORMAT, format);
if(request.getOperator().equals("between")){
whereName = String.format(ImpalaConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : ImpalaConstants.DEFAULT_DATE_FORMAT, ImpalaConstants.DEFAULT_DATE_FORMAT);
}else {
whereName = String.format(ImpalaConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : ImpalaConstants.DEFAULT_DATE_FORMAT, format);
}
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(ImpalaConstants.FROM_UNIXTIME, cast, format);
if(request.getOperator().equals("between")){
String cast = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(ImpalaConstants.FROM_UNIXTIME, cast, ImpalaConstants.DEFAULT_DATE_FORMAT);
}else {
String cast = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(ImpalaConstants.FROM_UNIXTIME, cast, format);
}
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = String.format(ImpalaConstants.DATE_FORMAT, originName, format);
if(request.getOperator().equals("between")){
whereName = originName;
}else {
whereName = String.format(ImpalaConstants.DATE_FORMAT, originName, format);
}
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {

View File

@ -1065,16 +1065,33 @@ public class MysqlQueryProvider extends QueryProvider {
if (field.getDeType() == 1) {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
if (StringUtils.equalsIgnoreCase(request.getDateStyle(), "y_Q")) {
whereName = String.format(format,
String.format(MysqlConstants.DATE_FORMAT, originName, "%Y"),
String.format(MysqlConstants.QUARTER, String.format(MysqlConstants.DATE_FORMAT, originName, MysqlConstants.DEFAULT_DATE_FORMAT)));
} else {
whereName = String.format(MySQLConstants.DATE_FORMAT, originName, format);
String date = String.format(MySQLConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : MysqlConstants.DEFAULT_DATE_FORMAT);
if(request.getOperator().equals("between")){
whereName = date;
}else {
if (StringUtils.equalsIgnoreCase(request.getDateStyle(), "y_Q")) {
whereName = String.format(format,
String.format(MysqlConstants.DATE_FORMAT, originName, "%Y"),
String.format(MysqlConstants.QUARTER, String.format(MysqlConstants.DATE_FORMAT, originName, MysqlConstants.DEFAULT_DATE_FORMAT)));
} else {
whereName = String.format(MySQLConstants.DATE_FORMAT, date, format);
}
}
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
if(request.getOperator().equals("between")){
whereName = originName;
}else {
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
if (StringUtils.equalsIgnoreCase(request.getDateStyle(),"y_Q")){
whereName = String.format(format,
String.format(MysqlConstants.DATE_FORMAT, cast, "%Y"),
String.format(MysqlConstants.QUARTER, String.format(MysqlConstants.DATE_FORMAT, field, MysqlConstants.DEFAULT_DATE_FORMAT)));
} else {
whereName = String.format(MySQLConstants.DATE_FORMAT, cast, format);
}
}
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {

View File

@ -1208,14 +1208,14 @@ public class OracleQueryProvider extends QueryProvider {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if(!request.getOperator().equals("between")){
whereName = String.format(OracleConstants.TO_CHAR, String.format(OracleConstants.TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : OracleConstants.DEFAULT_DATE_FORMAT), format);
}else {
whereName = String.format(OracleConstants.TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : OracleConstants.DEFAULT_DATE_FORMAT);
}
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if(!request.getOperator().equals("between")){
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, format);
}else {
@ -1224,7 +1224,7 @@ public class OracleQueryProvider extends QueryProvider {
}
}
if (field.getDeExtractType() == 1) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if(!request.getOperator().equals("between")){
whereName = String.format(OracleConstants.TO_CHAR, originName, format);
}else {
whereName = originName;

View File

@ -1074,30 +1074,29 @@ public class PgQueryProvider extends QueryProvider {
if (field.getDeType() == 1) {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
String timestamp = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
String timestamp = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
if(request.getOperator().equals("between")){
whereName = timestamp;
}else {
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
} else {
whereName = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
}
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
String timestamp = String.format(PgConstants.FROM_UNIXTIME, cast);
String cast = String.format(PgConstants.CAST, originName, "bigint");
String timestamp = String.format(PgConstants.FROM_UNIXTIME, cast);
if(request.getOperator().equals("between")){
whereName = timestamp;
}else {
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
} else {
String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
}
}
if (field.getDeExtractType() == 1) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereName = String.format(PgConstants.DATE_FORMAT, originName, format);
} else {
if(request.getOperator().equals("between")){
whereName = originName;
}else {
whereName = String.format(PgConstants.DATE_FORMAT, originName, format);
}
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {

View File

@ -1070,15 +1070,27 @@ public class RedshiftQueryProvider extends QueryProvider {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
String timestamp = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
if(request.getOperator().equals("between")){
whereName = timestamp;
}else {
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
}
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
String timestamp = String.format(PgConstants.FROM_UNIXTIME, cast);
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
if(request.getOperator().equals("between")){
whereName = timestamp;
}else {
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
}
}
if (field.getDeExtractType() == 1) {
whereName = String.format(PgConstants.DATE_FORMAT, originName, format);
if(request.getOperator().equals("between")){
whereName = originName;
}else {
whereName = String.format(PgConstants.DATE_FORMAT, originName, format);
}
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {

View File

@ -1098,14 +1098,14 @@ public class SqlserverQueryProvider extends QueryProvider {
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if (!StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), String.format(SqlServerSQLConstants.STRING_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SqlServerSQLConstants.DEFAULT_DATE_FORMAT));
}else {
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SqlServerSQLConstants.DEFAULT_DATE_FORMAT);
}
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if (!StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), cast);
}else {
@ -1114,7 +1114,7 @@ public class SqlserverQueryProvider extends QueryProvider {
}
}
if (field.getDeExtractType() == 1) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if (!StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), originName);
}else {
whereName = originName;