mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
fix:Solve the problem of conflicts between indicators and dimensions in indicator exploration. (#1493)
* fix:1.解决指标探索中指标与维度冲突的问题2.解决维度值分布因时间筛选无法查询查到数据的问题 * fix:恢复时间筛选 --------- Co-authored-by: sunhan <sunhan19981031@163.com>
This commit is contained in:
@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.calcite.sql.SqlNode;
|
||||
import org.apache.calcite.sql.validate.SqlValidatorScope;
|
||||
import org.apache.calcite.util.Litmus;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -91,6 +92,9 @@ public class SourceRender extends Renderer {
|
||||
scope);
|
||||
}
|
||||
|
||||
output.setMeasure(deduplicateNode(output.getMeasure()));
|
||||
dataSet.setMeasure(deduplicateNode(dataSet.getMeasure()));
|
||||
|
||||
SqlNode tableNode = DataSourceNode.buildExtend(datasource, extendFields, scope);
|
||||
dataSet.setTable(tableNode);
|
||||
output.setTable(SemanticNode.buildAs(
|
||||
@@ -99,6 +103,25 @@ public class SourceRender extends Renderer {
|
||||
return output;
|
||||
}
|
||||
|
||||
private static List<SqlNode> deduplicateNode(List<SqlNode> listNode) { //List<SqlNode>去重
|
||||
List<SqlNode> uniqueElements = new ArrayList<>();
|
||||
for (SqlNode element : listNode) {
|
||||
if (!containsElement(uniqueElements, element)) {
|
||||
uniqueElements.add(element);
|
||||
}
|
||||
}
|
||||
return uniqueElements;
|
||||
}
|
||||
|
||||
private static boolean containsElement(List<SqlNode> list, SqlNode element) { //检查List<SqlNode>中是否含有某element
|
||||
for (SqlNode i : list) {
|
||||
if (i.equalsDeep(element, Litmus.IGNORE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void buildDimension(String alias, String dimension, DataSource datasource, SemanticSchema schema,
|
||||
boolean nonAgg, Map<String, String> extendFields, TableView dataSet, TableView output,
|
||||
SqlValidatorScope scope)
|
||||
|
||||
Reference in New Issue
Block a user