forked from github/dataease
Merge pull request #8559 from dataease/pr@dev@feat_date
feat(视图): ClickHouse, Oracle支持年季度、年周
This commit is contained in:
commit
6d974ae409
@ -1427,7 +1427,17 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originName), format);
|
||||
if (StringUtils.equalsIgnoreCase(request.getDateStyle(), "y_Q")) {
|
||||
whereName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originName + ")"),
|
||||
String.format(CKConstants.toQuarter, "toDate(" + originName + ")"));
|
||||
} else if (StringUtils.equalsIgnoreCase(request.getDateStyle(), "y_W")) {
|
||||
whereName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originName + ")"),
|
||||
String.format(CKConstants.toWeek, "toDate(" + originName + ")"));
|
||||
} else {
|
||||
whereName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originName), format);
|
||||
}
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(CKConstants.toFloat64, originName);
|
||||
@ -1540,8 +1550,12 @@ public class CKQueryProvider extends QueryProvider {
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "%Y";
|
||||
case "y_Q":
|
||||
return "CONCAT(%s,'" + split + "','Q',%s)";
|
||||
case "y_M":
|
||||
return "%Y" + split + "%m";
|
||||
case "y_W":
|
||||
return "CONCAT(%s,'" + split + "','W',%s)";
|
||||
case "y_M_d":
|
||||
return "%Y" + split + "%m" + split + "%d";
|
||||
case "H_m_s":
|
||||
@ -1568,7 +1582,17 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
fieldName = String.format(CKConstants.formatDateTime, originField, format);
|
||||
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toQuarter, "toDate(" + originField + ")"));
|
||||
} else if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_W")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toWeek, "toDate(" + originField + ")"));
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, originField, format);
|
||||
}
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
@ -1576,9 +1600,29 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originField), format);
|
||||
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toQuarter, "toDate(" + originField + ")"));
|
||||
} else if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_W")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toWeek, "toDate(" + originField + ")"));
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originField), format);
|
||||
}
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, String.format(CKConstants.toFloat64, originField)), format);
|
||||
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toQuarter, "toDate(" + originField + ")"));
|
||||
} else if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_W")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toWeek, "toDate(" + originField + ")"));
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, String.format(CKConstants.toFloat64, originField)), format);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (x.getDeType() == DeTypeConstants.DE_INT) {
|
||||
|
@ -1604,8 +1604,12 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "YYYY";
|
||||
case "y_Q":
|
||||
return "YYYY" + split + "\"Q\"Q";
|
||||
case "y_M":
|
||||
return "YYYY" + split + "MM";
|
||||
case "y_W":
|
||||
return "YYYY" + split + "\"W\"IW";
|
||||
case "y_M_d":
|
||||
return "YYYY" + split + "MM" + split + "DD";
|
||||
case "H_m_s":
|
||||
|
@ -335,6 +335,8 @@ export default {
|
||||
this.showDateExt = (this.chart.datasourceType === 'mysql' ||
|
||||
this.chart.datasourceType === 'ds_doris' ||
|
||||
this.chart.datasourceType === 'StarRocks' ||
|
||||
this.chart.datasourceType === 'ck' ||
|
||||
this.chart.datasourceType === 'oracle' ||
|
||||
this.chart.datasetMode === 1) && this.chart.type !== 'bar-time-range'
|
||||
} else {
|
||||
this.showDateExt = false
|
||||
|
@ -356,6 +356,8 @@ export default {
|
||||
this.showDateExt = this.chart.datasourceType === 'mysql' ||
|
||||
this.chart.datasourceType === 'ds_doris' ||
|
||||
this.chart.datasourceType === 'StarRocks' ||
|
||||
this.chart.datasourceType === 'ck' ||
|
||||
this.chart.datasourceType === 'oracle' ||
|
||||
this.chart.datasetMode === 1
|
||||
} else {
|
||||
this.showDateExt = false
|
||||
|
@ -40,5 +40,10 @@ public class CKConstants extends SQLConstants {
|
||||
|
||||
public static final String GROUP_CONCAT = "arrayStringConcat(groupArray(%s), ',')";
|
||||
|
||||
public static final String toYear = "toYear(%s)";
|
||||
|
||||
public static final String toWeek = "toWeek(%s, 5)";
|
||||
|
||||
public static final String toQuarter = "toQuarter(%s)";
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user