diff --git a/core/datacap-common/src/main/java/io/edurt/datacap/common/sql/SqlBuilder.java b/core/datacap-common/src/main/java/io/edurt/datacap/common/sql/SqlBuilder.java index 6235e489..648e7533 100644 --- a/core/datacap-common/src/main/java/io/edurt/datacap/common/sql/SqlBuilder.java +++ b/core/datacap-common/src/main/java/io/edurt/datacap/common/sql/SqlBuilder.java @@ -108,7 +108,7 @@ public class SqlBuilder private List applyGroupByColumns() { return configure.getGroups().stream() - .map(v -> String.join(" ", String.format("`%s`", v.getColumn()))) + .map(v -> String.join(" ", String.format("%s", v.getColumn()))) .collect(Collectors.toList()); } diff --git a/core/datacap-service/src/main/java/io/edurt/datacap/service/body/adhoc/AdhocColumn.java b/core/datacap-service/src/main/java/io/edurt/datacap/service/body/adhoc/AdhocColumn.java index e243bf15..affc22d7 100644 --- a/core/datacap-service/src/main/java/io/edurt/datacap/service/body/adhoc/AdhocColumn.java +++ b/core/datacap-service/src/main/java/io/edurt/datacap/service/body/adhoc/AdhocColumn.java @@ -13,6 +13,7 @@ public class AdhocColumn { private Long id; private String expression; + private String function; private String alias; private String order; } diff --git a/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/DataSetServiceImpl.java b/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/DataSetServiceImpl.java index eefc3d51..64409f3c 100644 --- a/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/DataSetServiceImpl.java +++ b/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/DataSetServiceImpl.java @@ -175,9 +175,12 @@ public class DataSetServiceImpl configure.getColumns() .forEach(column -> columnRepository.findById(column.getId()) .ifPresent(entity -> { - String columnName = entity.getName(); AtomicReference columnAlias = new AtomicReference<>(null); AtomicReference expression = new AtomicReference<>(null); + AtomicReference columnName = new AtomicReference<>(entity.getName()); + if (StringUtils.isNotEmpty(column.getFunction())) { + columnName.set(column.getFunction()); + } configure.getColumns().stream() .filter(it -> it.getId().equals(entity.getId())) .findFirst() @@ -186,7 +189,7 @@ public class DataSetServiceImpl columnAlias.set(it.getAlias()); }); SqlColumn sqlColumn = SqlColumn.builder() - .column(columnName) + .column(columnName.get()) .expression(expression.get()) .alias(columnAlias.get()) .build(); @@ -194,7 +197,7 @@ public class DataSetServiceImpl // Only dimensions are added to GROUP BY if (entity.getMode().equals(ColumnMode.DIMENSION)) { groupBy.add(SqlColumn.builder() - .column(columnName) + .column(columnName.get()) .build()); } // Add to Sort Sequence @@ -300,14 +303,14 @@ public class DataSetServiceImpl { switch (type) { case NUMBER: - return "bigint"; + return "Bigint"; case NUMBER_SIGNED: return "UInt64"; case BOOLEAN: - return "boolean"; + return "Boolean"; case STRING: default: - return "varchar"; + return "String"; } } diff --git a/core/datacap-web/src/i18n/langs/en/dataset.ts b/core/datacap-web/src/i18n/langs/en/dataset.ts index 6258208a..059feed2 100644 --- a/core/datacap-web/src/i18n/langs/en/dataset.ts +++ b/core/datacap-web/src/i18n/langs/en/dataset.ts @@ -75,4 +75,5 @@ export default { columnExpressionAvg: 'Average', columnExpressionCount: 'Count', validatorSamplingTip: 'The order by key must contain a sampling key', + customFunction: 'Custom Function' } diff --git a/core/datacap-web/src/i18n/langs/zhCn/dataset.ts b/core/datacap-web/src/i18n/langs/zhCn/dataset.ts index 15059a55..d4ca3d32 100644 --- a/core/datacap-web/src/i18n/langs/zhCn/dataset.ts +++ b/core/datacap-web/src/i18n/langs/zhCn/dataset.ts @@ -74,5 +74,6 @@ export default { columnExpressionSum: '总和', columnExpressionAvg: '平均值', columnExpressionCount: '计数', - validatorSamplingTip: '排序键中必须包含抽样键' + validatorSamplingTip: '排序键中必须包含抽样键', + customFunction: '自定义函数' } diff --git a/core/datacap-web/src/views/admin/dataset/components/adhoc/DatasetColumnConfigure.vue b/core/datacap-web/src/views/admin/dataset/components/adhoc/DatasetColumnConfigure.vue index a8aa65ab..1ad94ec4 100644 --- a/core/datacap-web/src/views/admin/dataset/components/adhoc/DatasetColumnConfigure.vue +++ b/core/datacap-web/src/views/admin/dataset/components/adhoc/DatasetColumnConfigure.vue @@ -7,7 +7,7 @@ @onOk="handlerCommit()" @cancel="handlerCancel()">
+ :label-width="90"> +
@@ -91,7 +95,8 @@ export default defineComponent({ type: null, alias: null, expression: null, - order: null + order: null, + function: null } } },