(improvement)(semantic) Batch download compatible with empty data (#445)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2023-11-28 16:38:30 +08:00
committed by GitHub
parent b6734d99e1
commit 46733d1728
4 changed files with 15 additions and 4 deletions

View File

@@ -201,7 +201,6 @@ CREATE TABLE `s2_dictionary_task` (
CREATE TABLE `s2_dimension` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '维度ID',
`model_id` bigint(20) DEFAULT NULL,
`datasource_id` bigint(20) NOT NULL COMMENT '所属数据源id',
`name` varchar(255) NOT NULL COMMENT '维度名称',
`biz_name` varchar(255) NOT NULL COMMENT '字段名称',
`description` varchar(500) NOT NULL COMMENT '描述',

View File

@@ -115,4 +115,5 @@ CREATE TABLE s2_model_rela
PRIMARY KEY (`id`)
);
alter table s2_view_info change model_id domain_id bigint;
alter table s2_view_info change model_id domain_id bigint;
alter table s2_dimension drop column datasource_id;

View File

@@ -1,5 +1,6 @@
package com.tencent.supersonic.semantic.api.model.pojo;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -12,6 +13,6 @@ import java.util.List;
@Builder
public class RelateDimension {
List<DrillDownDimension> drillDownDimensions;
List<DrillDownDimension> drillDownDimensions = Lists.newArrayList();
}

View File

@@ -28,6 +28,7 @@ import com.tencent.supersonic.semantic.query.utils.DataTransformUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -197,7 +198,12 @@ public class DownloadServiceImpl implements DownloadService {
if ("指标名".equals(head)) {
continue;
}
row.add(map.getOrDefault(nameMap.getOrDefault(head, head), "").toString());
Object object = map.getOrDefault(nameMap.getOrDefault(head, head), "");
if (object == null) {
row.add("");
} else {
row.add(String.valueOf(object));
}
}
row.add(metricSchemaResp.getName());
data.add(row);
@@ -257,6 +263,10 @@ public class DownloadServiceImpl implements DownloadService {
private List<DimSchemaResp> getMetricRelaDimensions(MetricSchemaResp metricSchemaResp,
Map<Long, DimSchemaResp> dimensionRespMap) {
if (metricSchemaResp.getRelateDimension() == null
|| CollectionUtils.isEmpty(metricSchemaResp.getRelateDimension().getDrillDownDimensions())) {
return Lists.newArrayList();
}
return metricSchemaResp.getRelateDimension().getDrillDownDimensions()
.stream().map(drillDownDimension -> dimensionRespMap.get(drillDownDimension.getDimensionId()))
.filter(Objects::nonNull)