2 Commits

Author SHA1 Message Date
Jun Zhang
ef2f07a59e feat(dimension): 维度新增data_type字段支持 (#2435)
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled
2026-06-04 22:33:55 +08:00
jerryjzhang
c3cf8b1889 feat(data): 添加时间戳数据类型支持并优化维度转换逻辑
- 新增 TIMESTAMP 数据类型枚举值
- 为整型数据类型匹配添加 INT 关键字识别
- 移除维度转换中的冗余数据类型设置逻辑
- 修复数据类型转换过程中的潜在问题
2026-06-04 21:02:41 +08:00
6 changed files with 34 additions and 31 deletions

View File

@@ -26,12 +26,10 @@ public class SqlDialectFactory {
.withLiteralQuoteString("'").withIdentifierQuoteString("\"")
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
public static final Context PRESTO_CONTEXT =
SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.PRESTO)
.withLiteralQuoteString("'")
.withLiteralEscapedQuoteString("''")
.withUnquotedCasing(Casing.UNCHANGED)
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
public static final Context PRESTO_CONTEXT = SqlDialect.EMPTY_CONTEXT
.withDatabaseProduct(DatabaseProduct.PRESTO).withLiteralQuoteString("'")
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
public static final Context KYUUBI_CONTEXT =
SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.BIG_QUERY)
.withLiteralQuoteString("'").withIdentifierQuoteString("`")

View File

@@ -11,6 +11,8 @@ public enum DataTypeEnums {
DATE("DATE"),
TIMESTAMP("TIMESTAMP"),
BIGINT("BIGINT"),
INT("INT"),
@@ -39,6 +41,9 @@ public enum DataTypeEnums {
return typeEnum;
}
}
if (type != null && type.toUpperCase().contains("INT")) {
return DataTypeEnums.INT;
}
return DataTypeEnums.UNKNOWN;
}
}

View File

@@ -56,7 +56,8 @@ public class ChatQueryContext implements Serializable {
candidateQueries = candidateQueries.stream()
.sorted(Comparator.comparing(
semanticQuery -> semanticQuery.getParseInfo().getScore(),
Comparator.reverseOrder())).collect(Collectors.toList());
Comparator.reverseOrder()))
.collect(Collectors.toList());
return candidateQueries;
}

View File

@@ -79,11 +79,11 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
public DataSetResp getDataSet(Long id) {
DataSetDO dataSetDO = getById(id);
DataSetResp dataSetResp = convert(dataSetDO);
if (dataSetResp.getDataSetDetail() != null) {
expandIncludesAllModels(dataSetResp);
}
return dataSetResp;
}
@@ -286,10 +286,8 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
return;
}
Set<Long> includeAllModelIds = configs.stream()
.filter(DataSetModelConfig::getIncludesAll)
.map(DataSetModelConfig::getId)
.collect(Collectors.toSet());
Set<Long> includeAllModelIds = configs.stream().filter(DataSetModelConfig::getIncludesAll)
.map(DataSetModelConfig::getId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(includeAllModelIds)) {
return;
@@ -302,28 +300,26 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
List<DimensionResp> allDimensions = dimensionService.getDimensions(metaFilter);
List<MetricResp> allMetrics = metricService.getMetrics(metaFilter);
Map<Long, List<Long>> modelDimensionMap = allDimensions.stream()
.collect(Collectors.groupingBy(
DimensionResp::getModelId,
Collectors.mapping(DimensionResp::getId, Collectors.toList())
));
Map<Long, List<Long>> modelDimensionMap =
allDimensions.stream().collect(Collectors.groupingBy(DimensionResp::getModelId,
Collectors.mapping(DimensionResp::getId, Collectors.toList())));
Map<Long, List<Long>> modelMetricMap = allMetrics.stream()
.collect(Collectors.groupingBy(
MetricResp::getModelId,
Collectors.mapping(MetricResp::getId, Collectors.toList())
));
Map<Long, List<Long>> modelMetricMap =
allMetrics.stream().collect(Collectors.groupingBy(MetricResp::getModelId,
Collectors.mapping(MetricResp::getId, Collectors.toList())));
for (DataSetModelConfig config : configs) {
if (Boolean.TRUE.equals(config.getIncludesAll())) {
Long modelId = config.getId();
List<Long> modelDimensions = modelDimensionMap.getOrDefault(modelId, Lists.newArrayList());
List<Long> modelDimensions =
modelDimensionMap.getOrDefault(modelId, Lists.newArrayList());
Set<Long> existingDimensions = new HashSet<>(config.getDimensions());
existingDimensions.addAll(modelDimensions);
config.setDimensions(new ArrayList<>(existingDimensions));
List<Long> modelMetrics = modelMetricMap.getOrDefault(modelId, Lists.newArrayList());
List<Long> modelMetrics =
modelMetricMap.getOrDefault(modelId, Lists.newArrayList());
Set<Long> existingMetrics = new HashSet<>(config.getMetrics());
existingMetrics.addAll(modelMetrics);
config.setMetrics(new ArrayList<>(existingMetrics));

View File

@@ -73,9 +73,6 @@ public class DimensionConverter {
if (dimensionReq.getTypeParams() != null) {
dimensionDO.setTypeParams(JSONObject.toJSONString(dimensionReq.getTypeParams()));
}
if (dimensionReq.getDataType() != null) {
dimensionDO.setDataType(dimensionReq.getDataType().getType());
}
dimensionDO.setStatus(StatusEnum.ONLINE.getCode());
return dimensionDO;
}

View File

@@ -11,6 +11,7 @@
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="sensitive_level" jdbcType="INTEGER" property="sensitiveLevel"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="data_type" jdbcType="VARCHAR" property="dataType"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
@@ -67,14 +68,16 @@
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
insert into s2_dimension (name, biz_name,
description, status, model_id,
type, type_params, expr,created_at, created_by,
type, data_type, type_params, expr,created_at, created_by,
updated_by, updated_at, semantic_type,sensitive_level, is_tag, ext)
values
<foreach collection="list" item="dimension" separator=",">
(#{dimension.name,jdbcType=VARCHAR}, #{dimension.bizName,jdbcType=VARCHAR},
#{dimension.description,jdbcType=VARCHAR}, #{dimension.status,jdbcType=INTEGER},
#{dimension.modelId,jdbcType=BIGINT},
#{dimension.type,jdbcType=VARCHAR}, #{dimension.typeParams,jdbcType=VARCHAR},
#{dimension.type,jdbcType=VARCHAR},
#{dimension.dataType,jdbcType=VARCHAR},
#{dimension.typeParams,jdbcType=VARCHAR},
#{dimension.expr,jdbcType=VARCHAR}, #{dimension.createdAt,jdbcType=TIMESTAMP},
#{dimension.createdBy,jdbcType=VARCHAR},
#{dimension.updatedBy,jdbcType=VARCHAR}, #{dimension.updatedAt,jdbcType=TIMESTAMP},
@@ -98,6 +101,9 @@
<if test="dimension.status != null">status = #{dimension.status,jdbcType=INTEGER},</if>
<if test="dimension.modelId != null">model_id = #{dimension.modelId,jdbcType=BIGINT},</if>
<if test="dimension.type != null and dimension.type !=''">type = #{dimension.type,jdbcType=VARCHAR},</if>
<if test="dimension.dataType != null and dimension.dataType !=''">data_type =
#{dimension.dataType,jdbcType=VARCHAR},
</if>
<if test="dimension.typeParams != null and dimension.typeParams !=''">type_params =
#{dimension.typeParams,jdbcType=VARCHAR},
</if>