mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
(fixed)修正复合指标引用同一原子指标,替换时BUG (#1743)
This commit is contained in:
@@ -274,11 +274,17 @@ public class SqlGenerateUtils {
|
|||||||
return modelBizName + UNDERLINE + executorConfig.getInternalMetricNameSuffix();
|
return modelBizName + UNDERLINE + executorConfig.getInternalMetricNameSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateDerivedMetric(final List<MetricSchemaResp> metricResps,
|
public String generateDerivedMetric(
|
||||||
final Set<String> allFields, final Map<String, Measure> allMeasures,
|
final List<MetricSchemaResp> metricResps,
|
||||||
final List<DimSchemaResp> dimensionResps, final String expression,
|
final Set<String> allFields,
|
||||||
final MetricDefineType metricDefineType, AggOption aggOption, Set<String> visitedMetric,
|
final Map<String, Measure> allMeasures,
|
||||||
Set<String> measures, Set<String> dimensions) {
|
final List<DimSchemaResp> dimensionResps,
|
||||||
|
final String expression,
|
||||||
|
final MetricDefineType metricDefineType,
|
||||||
|
AggOption aggOption,
|
||||||
|
Map<String, String> visitedMetric,
|
||||||
|
Set<String> measures,
|
||||||
|
Set<String> dimensions) {
|
||||||
Set<String> fields = SqlSelectHelper.getColumnFromExpr(expression);
|
Set<String> fields = SqlSelectHelper.getColumnFromExpr(expression);
|
||||||
if (!CollectionUtils.isEmpty(fields)) {
|
if (!CollectionUtils.isEmpty(fields)) {
|
||||||
Map<String, String> replace = new HashMap<>();
|
Map<String, String> replace = new HashMap<>();
|
||||||
@@ -288,15 +294,24 @@ public class SqlGenerateUtils {
|
|||||||
Optional<MetricSchemaResp> metricItem = metricResps.stream()
|
Optional<MetricSchemaResp> metricItem = metricResps.stream()
|
||||||
.filter(m -> m.getBizName().equalsIgnoreCase(field)).findFirst();
|
.filter(m -> m.getBizName().equalsIgnoreCase(field)).findFirst();
|
||||||
if (metricItem.isPresent()) {
|
if (metricItem.isPresent()) {
|
||||||
if (visitedMetric.contains(field)) {
|
if (visitedMetric.keySet().contains(field)) {
|
||||||
|
replace.put(field, visitedMetric.get(field));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
replace.put(field,
|
replace.put(
|
||||||
generateDerivedMetric(metricResps, allFields, allMeasures,
|
field,
|
||||||
dimensionResps, getExpr(metricItem.get()),
|
generateDerivedMetric(
|
||||||
metricItem.get().getMetricDefineType(), aggOption,
|
metricResps,
|
||||||
visitedMetric, measures, dimensions));
|
allFields,
|
||||||
visitedMetric.add(field);
|
allMeasures,
|
||||||
|
dimensionResps,
|
||||||
|
getExpr(metricItem.get()),
|
||||||
|
metricItem.get().getMetricDefineType(),
|
||||||
|
aggOption,
|
||||||
|
visitedMetric,
|
||||||
|
measures,
|
||||||
|
dimensions));
|
||||||
|
visitedMetric.put(field, replace.get(field));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MEASURE:
|
case MEASURE:
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ public class QueryReqConverter {
|
|||||||
});
|
});
|
||||||
Set<String> deriveDimension = new HashSet<>();
|
Set<String> deriveDimension = new HashSet<>();
|
||||||
Set<String> deriveMetric = new HashSet<>();
|
Set<String> deriveMetric = new HashSet<>();
|
||||||
Set<String> visitedMetric = new HashSet<>();
|
Map<String, String> visitedMetric = new HashMap<>();
|
||||||
if (!CollectionUtils.isEmpty(metricResps)) {
|
if (!CollectionUtils.isEmpty(metricResps)) {
|
||||||
for (MetricResp metricResp : metricResps) {
|
for (MetricResp metricResp : metricResps) {
|
||||||
if (metrics.contains(metricResp.getBizName())) {
|
if (metrics.contains(metricResp.getBizName())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user