This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch kylin5 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 997b27fc9ec6da8e7a8f19ea9608c9c0907cff45 Author: Qian Xia <lauraxiaq...@gmail.com> AuthorDate: Wed Jul 5 18:36:29 2023 +0800 KYLIN-5617 sumlc measure datatype issue --- .../components/studio/StudioModel/AddMeasure/index.vue | 18 ++++++++++++------ kystudio/src/config/index.js | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/kystudio/src/components/studio/StudioModel/AddMeasure/index.vue b/kystudio/src/components/studio/StudioModel/AddMeasure/index.vue index c2426847ff..8a80e0e7c5 100644 --- a/kystudio/src/components/studio/StudioModel/AddMeasure/index.vue +++ b/kystudio/src/components/studio/StudioModel/AddMeasure/index.vue @@ -197,9 +197,9 @@ <span class="ky-option-sub-info">{{item.datatype.toLocaleLowerCase()}}</span> </el-option> </el-option-group> - <el-option-group key="ccolumn" :label="$t('ccolumns')" v-if="getCCGroups().length || newCCList.length"> + <el-option-group key="ccolumn" :label="$t('ccolumns')" v-if="getCCGroups(null, true).length || newCCList.length"> <el-option - v-for="item in getCCGroups()" + v-for="item in getCCGroups(null, true)" :key="item.guid" :label="item.tableAlias + '.' + item.columnName" :value="item.tableAlias + '.' + item.columnName"> @@ -240,7 +240,7 @@ <script> import Vue from 'vue' import { Component, Watch } from 'vue-property-decorator' -import { measuresDataType, measureSumAndTopNDataType, measurePercenDataType } from '../../../../config' +import { measuresDataType, measureSumAndTopNDataType, measurePercenDataType, measuresDateTimeDataType } from '../../../../config' import { objectClone, sampleGuid, indexOfObjWithSomeKey, handleSuccessAsync } from '../../../../util/index' import { measureNameRegex } from 'config' import CCEditForm from '../ComputedColumnForm/ccform.vue' @@ -416,9 +416,9 @@ export default class AddMeasure extends Vue { expression: [{ required: true, message: this.$t('requiredExpress'), trigger: 'change' }] } } - getCCGroups (isGroupBy) { + getCCGroups (isGroupBy, isSumlc) { if (this.ccGroups.length) { - if (this.measure.expression === 'SUM(column)' || this.measure.expression === 'CORR') { + if (this.measure.expression === 'SUM(column)' || (this.measure.expression === 'SUM_LC' && !isSumlc) || this.measure.expression === 'CORR') { return this.ccGroups.filter(it => measureSumAndTopNDataType.includes(it.datatype.toLocaleLowerCase().match(/^(\w+)\(?/)[1])) } else if (this.measure.expression === 'TOP_N') { if (isGroupBy && isGroupBy === 'Group by') { @@ -428,6 +428,8 @@ export default class AddMeasure extends Vue { } } else if (this.measure.expression === 'PERCENTILE_APPROX') { return this.ccGroups.filter(item => measurePercenDataType.includes(item.datatype.toLocaleLowerCase().match(/^(\w+)\(?/)[1])) + } else if (this.measure.expression === 'SUM_LC' && isSumlc) { + return this.ccGroups.filter(it => measuresDateTimeDataType.includes(it.datatype.toLocaleLowerCase().match(/^(\w+)\(?/)[1])) } else { return this.ccGroups } @@ -753,10 +755,14 @@ export default class AddMeasure extends Vue { // 支持measure的任意类型 get getParameterValue2 () { let targetColumns = [] + let filterType = measuresDataType + if (this.measure.expression === 'SUM_LC') { + filterType = measuresDateTimeDataType + } $.each(this.allTableColumns, (index, column) => { const returnRegex = new RegExp('(\\w+)(?:\\((\\w+?)(?:\\,(\\w+?))?\\))?') const returnValue = returnRegex.exec(column.datatype) - if (measuresDataType.indexOf(returnValue[1]) >= 0 && !this.flattenLookupTables.includes(column.table_alias)) { + if (filterType.indexOf(returnValue[1]) >= 0 && !this.flattenLookupTables.includes(column.table_alias)) { const columnObj = {name: column.table_alias + '.' + column.name, datatype: column.datatype} targetColumns.push(columnObj) } diff --git a/kystudio/src/config/index.js b/kystudio/src/config/index.js index f35e572b7d..160a285fa0 100644 --- a/kystudio/src/config/index.js +++ b/kystudio/src/config/index.js @@ -226,6 +226,10 @@ export const measuresDataType = [ 'tinyint', 'smallint', 'integer', 'bigint', 'float', 'double', 'decimal', 'timestamp', 'date', 'char', 'varchar', 'boolean' ] +export const measuresDateTimeDataType = [ + 'smallint', 'integer', 'bigint', 'timestamp', 'date', 'char', 'varchar' +] + export const measureSumAndTopNDataType = ['tinyint', 'smallint', 'integer', 'bigint', 'float', 'double', 'decimal'] export const measurePercenDataType = ['tinyint', 'smallint', 'integer', 'bigint']