Merge pull request #4967 from dataease/pr@dev@feat_chart_date

feat(视图): Doris,StarRocks同环比支持周,季度
This commit is contained in:
Junjun 2023-04-06 10:09:17 +08:00 committed by GitHub
commit 6a7e597c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1392 additions and 1363 deletions

View File

@ -1155,8 +1155,12 @@ public class DorisQueryProvider extends QueryProvider {
switch (dateStyle) {
case "y":
return "%Y";
case "y_Q":
return "CONCAT(%s,'" + split + "',%s)";
case "y_M":
return "%Y" + split + "%m";
case "y_W":
return "%Y" + split + "%u";
case "y_M_d":
return "%Y" + split + "%m" + split + "%d";
case "H_m_s":
@ -1177,7 +1181,13 @@ public class DorisQueryProvider extends QueryProvider {
fieldName = String.format(DorisConstants.UNIX_TIMESTAMP, originField) + "*1000";
} else if (x.getDeType() == 1) {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
fieldName = String.format(format,
String.format(DorisConstants.DATE_FORMAT, originField, "%Y"),
String.format(DorisConstants.QUARTER, originField));
} else {
fieldName = String.format(DorisConstants.DATE_FORMAT, originField, format);
}
} else {
fieldName = originField;
}
@ -1185,12 +1195,25 @@ public class DorisQueryProvider extends QueryProvider {
if (x.getDeType() == 1) {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
if (x.getDeExtractType() == 0) {
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
fieldName = String.format(format,
String.format(DorisConstants.DATE_FORMAT, String.format(DorisConstants.STR_TO_DATE, originField, DorisConstants.DEFAULT_DATE_FORMAT), "%Y"),
String.format(DorisConstants.QUARTER, String.format(DorisConstants.STR_TO_DATE, originField, DorisConstants.DEFAULT_DATE_FORMAT)));
} else {
fieldName = String.format(DorisConstants.DATE_FORMAT, String.format(DorisConstants.STR_TO_DATE, originField, StringUtils.isNotEmpty(x.getDateFormat()) ? x.getDateFormat() : DorisConstants.DEFAULT_DATE_FORMAT), format);
}
} else {
String cast = String.format(DorisConstants.CAST, originField, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
String from_unixtime = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
fieldName = String.format(format,
String.format(DorisConstants.DATE_FORMAT, from_unixtime, "%Y"),
String.format(DorisConstants.QUARTER, from_unixtime));
} else {
fieldName = String.format(DorisConstants.DATE_FORMAT, from_unixtime, format);
}
}
} else if (x.getDeType() == 0) {
fieldName = String.format(DorisConstants.CAST, originField, DorisConstants.VARCHAR);
} else {

View File

@ -298,7 +298,10 @@ export default {
},
getDateExtStatus() {
if (this.chart) {
this.showDateExt = this.chart.datasourceType === 'mysql' && this.chart.datasetMode === 0
this.showDateExt = this.showDateExt = this.chart.datasourceType === 'mysql' ||
this.chart.datasourceType === 'ds_doris' ||
this.chart.datasourceType === 'StarRocks' ||
this.chart.datasetMode === 1
} else {
this.showDateExt = false
}

View File

@ -342,7 +342,10 @@ export default {
getDateExtStatus() {
if (this.chart) {
this.showDateExt = this.chart.datasourceType === 'mysql' && this.chart.datasetMode === 0
this.showDateExt = this.chart.datasourceType === 'mysql' ||
this.chart.datasourceType === 'ds_doris' ||
this.chart.datasourceType === 'StarRocks' ||
this.chart.datasetMode === 1
} else {
this.showDateExt = false
}