13 Commits

Author SHA1 Message Date
jerryjzhang
de60be3908 refactor(model): default measure agg to none.
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-23 22:40:10 +08:00
jerryjzhang
0868850edd fix(headless): 解决数据集维度数据类型映射空指针异常
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
- 添加对 dataTypeMap 的 containsKey 检查避免空指针异常
- 修复维度数据类型映射逻辑中的潜在运行时错误
- 确保在模型ID不存在时跳过数据类型映射操作
2026-06-20 17:43:12 +08:00
jerryjzhang
6d41ce4c5b fix(mapper): 优先按相似度排序并保留所有完全匹配项
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-09 19:48:02 +08:00
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
jerryjzhang
c0af25fe2e feat(db): 添加对 Hive 数据库引擎的支持
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
- 在 EngineType 枚举中添加 HIVE 类型定义
2026-05-29 12:17:57 +08:00
jerryjzhang
d2ae1509cb refactor(chat): 优化候选查询排序逻辑
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
- 移除不必要的 limit(1) 操作以保留所有排序后的候选查询
- 保持按分数降序排列的排序规则不变
2026-05-27 20:12:02 +08:00
jerryjzhang
5b77b39c60 feat(dimension): 添加维度数据类型支持
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
- 在Dimension类中新增dataType字段
- 更新Dimension构造函数以支持dataType参数
- 在DimensionConverter中添加dataType转换逻辑
- 在ModelConverter中集成DataTypeEnums转换
- 支持从语义列到维度的数据类型映射
2026-05-22 17:45:46 +08:00
jerryjzhang
9f2262c97b fix(common): 解决日期范围解析中的空指针异常
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-05-09 10:53:46 +08:00
jerryjzhang
6f11cdc12c refactor: 移除未使用的 ModelService 依赖
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-05-08 19:14:48 +08:00
jerryjzhang
3752543921 feat(dataset): 实现数据集模型配置中的全量维度指标扩展功能
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
- 实现 expandIncludesAllModels 方法处理全量维度指标映射
- 根据模型ID分组收集维度和指标并合并到配置中
- 将 includesAll 标志重置为 false 避免重复扩展
- 确保在线状态的维度和指标被正确包含到数据集中
2026-05-07 15:51:57 +08:00
jerryjzhang
20cd98332c Merge branch 'master' of https://github.com/tencentmusic/supersonic
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-04-28 20:56:50 +08:00
jerryjzhang
a4253784be refactor(common): 移除 Presto 上下文中的标识符引用字符串配置
- 移除了 .withIdentifierQuoteString("\"") 配置项
- 保持了字面量引号和转义引号字符串配置
- 维持了大小写敏感性和未引用名称的大小写不变设置
2026-04-28 20:55:40 +08:00
14 changed files with 106 additions and 26 deletions

View File

@@ -26,11 +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("'").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 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

@@ -14,7 +14,8 @@ public enum EngineType {
KYUUBI(11, "KYUUBI"),
PRESTO(12, "PRESTO"),
TRINO(13, "TRINO"),
ORACLE(14, "ORACLE");
ORACLE(14, "ORACLE"),
HIVE(15, "HIVE");
private Integer code;

View File

@@ -181,6 +181,11 @@ public class DateUtils {
LocalDate startDate = parseDate(startDateStr);
LocalDate endDate = parseDate(endDateStr);
List<String> datesInRange = new ArrayList<>();
if (startDate == null || endDate == null) {
return datesInRange;
}
LocalDate currentDate = startDate;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
while (!currentDate.isAfter(endDate)) {

View File

@@ -21,6 +21,8 @@ public class Dimension {
private String dateFormat = Constants.DAY_FORMAT;
private String dataType;
private DimensionTimeTypeParams typeParams;
private Integer isCreateDimension = 0;
@@ -37,13 +39,14 @@ public class Dimension {
this.expr = bizName;
}
public Dimension(String name, String bizName, String expr, DimensionType type,
public Dimension(String name, String bizName, String expr, DimensionType type, String dataType,
Integer isCreateDimension) {
this.name = name;
this.type = type;
this.isCreateDimension = isCreateDimension;
this.bizName = bizName;
this.expr = expr;
this.dataType = dataType;
}
public Dimension(String name, String bizName, DimensionType type, Integer isCreateDimension,

View File

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

View File

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -50,8 +51,12 @@ public class HanlpDictMatchStrategy extends SingleMatchStrategy<HanlpMapResult>
return new ArrayList<>();
}
// step3. merge pre/suffix result
// sort by similarity (desc) first, then name length (desc), so that
// higher-similarity records are inserted first and survive LinkedHashSet dedup
hanlpMapResults = hanlpMapResults.stream()
.sorted((a, b) -> -(b.getName().length() - a.getName().length()))
.sorted(Comparator.comparingDouble(HanlpMapResult::getSimilarity).reversed()
.thenComparing((a, b) -> Integer.compare(b.getName().length(),
a.getName().length())))
.collect(Collectors.toCollection(LinkedHashSet::new));
// step4. filter by similarity

View File

@@ -123,15 +123,9 @@ public class MapFilter {
.filter(SchemaElementMatch::isFullMatched).collect(Collectors.toList());
if (!fullMatches.isEmpty()) {
// If there are objects with similarity=1.0, choose the one with the longest
// detectWord and smallest offset
SchemaElementMatch bestMatch = fullMatches.stream()
.max(Comparator.comparing(
(SchemaElementMatch match) -> match.getDetectWord().length()))
.orElse(null);
if (bestMatch != null) {
result.add(bestMatch);
}
// Keep all records with similarity=1.0, as they may correspond to different
// elementIds with the same detectWord
result.addAll(fullMatches);
} else {
// If there are no objects with similarity=1.0, keep all objects with similarity<1.0
result.addAll(group);

View File

@@ -24,6 +24,7 @@ public class DbAdaptorFactory {
dbAdaptorMap.put(EngineType.TRINO.getName(), new TrinoAdaptor());
dbAdaptorMap.put(EngineType.ORACLE.getName(), new OracleAdaptor());
dbAdaptorMap.put(EngineType.TDW.getName(), new DefaultDbAdaptor());
dbAdaptorMap.put(EngineType.HIVE.getName(), new DefaultDbAdaptor());
}
public static DbAdaptor getEngineAdaptor(String engineType) {

View File

@@ -13,6 +13,7 @@ import com.tencent.supersonic.common.pojo.enums.TypeEnums;
import com.tencent.supersonic.common.pojo.exception.InvalidArgumentException;
import com.tencent.supersonic.common.util.BeanMapper;
import com.tencent.supersonic.headless.api.pojo.DataSetDetail;
import com.tencent.supersonic.headless.api.pojo.DataSetModelConfig;
import com.tencent.supersonic.headless.api.pojo.MetaFilter;
import com.tencent.supersonic.headless.api.pojo.QueryConfig;
import com.tencent.supersonic.headless.api.pojo.request.*;
@@ -77,7 +78,13 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
@Override
public DataSetResp getDataSet(Long id) {
DataSetDO dataSetDO = getById(id);
return convert(dataSetDO);
DataSetResp dataSetResp = convert(dataSetDO);
if (dataSetResp.getDataSetDetail() != null) {
expandIncludesAllModels(dataSetResp);
}
return dataSetResp;
}
@Override
@@ -273,6 +280,55 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
.map(Object::toString).collect(Collectors.toList());
}
private void expandIncludesAllModels(DataSetResp dataSetResp) {
List<DataSetModelConfig> configs = dataSetResp.getDataSetDetail().getDataSetModelConfigs();
if (CollectionUtils.isEmpty(configs)) {
return;
}
Set<Long> includeAllModelIds = configs.stream().filter(DataSetModelConfig::getIncludesAll)
.map(DataSetModelConfig::getId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(includeAllModelIds)) {
return;
}
MetaFilter metaFilter = new MetaFilter();
metaFilter.setModelIds(new ArrayList<>(includeAllModelIds));
metaFilter.setStatus(StatusEnum.ONLINE.getCode());
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>> 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());
Set<Long> existingDimensions = new HashSet<>(config.getDimensions());
existingDimensions.addAll(modelDimensions);
config.setDimensions(new ArrayList<>(existingDimensions));
List<Long> modelMetrics =
modelMetricMap.getOrDefault(modelId, Lists.newArrayList());
Set<Long> existingMetrics = new HashSet<>(config.getMetrics());
existingMetrics.addAll(modelMetrics);
config.setMetrics(new ArrayList<>(existingMetrics));
config.setIncludesAll(false);
}
}
}
public Long getDataSetIdFromSql(String sql, User user) {
List<DataSetResp> dataSets = null;
try {

View File

@@ -123,8 +123,10 @@ public class DataSetSchemaBuilder {
dimToAdd.getExtInfo().put(DimensionConstants.DIMENSION_DATA_TYPE,
dim.getDataType());
} else {
dimToAdd.getExtInfo().put(DimensionConstants.DIMENSION_DATA_TYPE,
dataTypeMap.get(dim.getModelId()).get(dim.getBizName()));
if (dataTypeMap.containsKey(dim.getModelId())) {
dimToAdd.getExtInfo().put(DimensionConstants.DIMENSION_DATA_TYPE,
dataTypeMap.get(dim.getModelId()).get(dim.getBizName()));
}
}
if (dim.isTimeDimension()) {
String timeFormat =

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.tencent.supersonic.common.pojo.DimensionConstants;
import com.tencent.supersonic.common.pojo.User;
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
import com.tencent.supersonic.common.util.BeanMapper;
import com.tencent.supersonic.common.util.JsonUtil;
@@ -109,6 +110,7 @@ public class ModelConverter {
dimensionReq.setModelId(modelDO.getId());
dimensionReq.setExpr(dim.getExpr());
dimensionReq.setType(dim.getType().name());
dimensionReq.setDataType(DataTypeEnums.of(dim.getDataType()));
dimensionReq
.setDescription(Objects.isNull(dim.getDescription()) ? dimensionReq.getDescription()
: dim.getDescription());
@@ -193,7 +195,8 @@ public class ModelConverter {
if (optional.isEmpty()) {
Dimension dim = new Dimension(semanticColumn.getName(),
semanticColumn.getColumnName(), semanticColumn.getExpr(),
DimensionType.valueOf(semanticColumn.getFiledType().name()), 1);
DimensionType.valueOf(semanticColumn.getFiledType().name()),
semanticColumn.getDataType(), 1);
modelDetail.getDimensions().add(dim);
}
}

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>

View File

@@ -105,7 +105,7 @@ const ModelFieldForm: React.FC<Props> = ({
let defaultParams:any = {};
if (value === EnumDataSourceType.MEASURES) {
defaultParams = {
agg: AGG_OPTIONS[0].value,
agg: AGG_OPTIONS[AGG_OPTIONS.length - 1].value,
classType: EnumDataSourceType.MEASURES,
type: EnumDataSourceType.MEASURES,
};
@@ -217,7 +217,7 @@ const ModelFieldForm: React.FC<Props> = ({
handleFieldChange(record, 'agg', value);
}}
allowClear
defaultValue={AGG_OPTIONS[0].value}
defaultValue={AGG_OPTIONS[AGG_OPTIONS.length - 1].value}
style={{ width: '100%' }}
>
{AGG_OPTIONS.map((item) => (