Skip to content

Commit 47c2595

Browse files
authored
(fix)(headless) preserve model join order by using LinkedHashSet in probeRelatedModels (#2299)
1 parent 9bddd44 commit 47c2595

File tree

1 file changed

+3
-3
lines changed
  • headless/core/src/main/java/com/tencent/supersonic/headless/core/translator/parser/calcite

1 file changed

+3
-3
lines changed

headless/core/src/main/java/com/tencent/supersonic/headless/core/translator/parser/calcite/SqlBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private Set<ModelResp> probeRelatedModels(Set<ModelResp> dataModels, Ontology on
8888
GraphPath<String, DefaultEdge> selectedGraphPath = null;
8989
for (String fromModel : queryModels) {
9090
for (String toModel : queryModels) {
91-
if (fromModel != toModel) {
91+
if (!fromModel.equals(toModel)) {
9292
GraphPath<String, DefaultEdge> path = dijkstraAlg.getPath(fromModel, toModel);
9393
if (isGraphPathContainsAll(path, queryModels)) {
9494
selectedGraphPath = path;
@@ -100,13 +100,13 @@ private Set<ModelResp> probeRelatedModels(Set<ModelResp> dataModels, Ontology on
100100
if (selectedGraphPath == null) {
101101
return dataModels;
102102
}
103-
Set<String> modelNames = Sets.newHashSet();
103+
Set<String> modelNames = Sets.newLinkedHashSet();
104104
for (DefaultEdge edge : selectedGraphPath.getEdgeList()) {
105105
modelNames.add(selectedGraphPath.getGraph().getEdgeSource(edge));
106106
modelNames.add(selectedGraphPath.getGraph().getEdgeTarget(edge));
107107
}
108108
return modelNames.stream().map(m -> ontology.getModelMap().get(m))
109-
.collect(Collectors.toSet());
109+
.collect(Collectors.toCollection(LinkedHashSet::new));
110110
}
111111

112112
private boolean isGraphPathContainsAll(GraphPath<String, DefaultEdge> graphPath,

0 commit comments

Comments
 (0)