mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-30 13:04:27 +08:00
Compare commits
1 Commits
f973faba04
...
32ba5e2049
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32ba5e2049 |
@@ -343,25 +343,18 @@ public class DataModelNode extends SemanticNode {
|
|||||||
Map<String, Long> orders = new HashMap<>();
|
Map<String, Long> orders = new HashMap<>();
|
||||||
joinDataModelNames.add(baseDataModel.getName());
|
joinDataModelNames.add(baseDataModel.getName());
|
||||||
orders.put(baseDataModel.getName(), 0L);
|
orders.put(baseDataModel.getName(), 0L);
|
||||||
|
|
||||||
// Adjust the order of tables in the data source to facilitate subsequent joins
|
|
||||||
ArrayList<String> joinTables = new ArrayList<>();
|
|
||||||
for (JoinRelation joinRelation : ontology.getJoinRelations()) {
|
for (JoinRelation joinRelation : ontology.getJoinRelations()) {
|
||||||
if (joinDataModelNames.contains(joinRelation.getLeft())
|
if (joinDataModelNames.contains(joinRelation.getLeft())
|
||||||
&& joinDataModelNames.contains(joinRelation.getRight())) {
|
&& joinDataModelNames.contains(joinRelation.getRight())) {
|
||||||
joinTables.add(joinRelation.getLeft());
|
orders.put(joinRelation.getLeft(), 0L);
|
||||||
joinTables.add(joinRelation.getRight());
|
orders.put(joinRelation.getRight(), 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String joinTable : joinTables) {
|
orders.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEach(d -> {
|
||||||
orders.put(joinTable, orders.getOrDefault(joinTable, 0L) + 1L);
|
|
||||||
}
|
|
||||||
orders.entrySet().stream()
|
|
||||||
.sorted((entry1, entry2) -> entry2.getValue().compareTo(entry1.getValue())) // 倒序排序
|
|
||||||
.forEach(d -> {
|
|
||||||
joinDataModels.add(ontology.getDataModelMap().get(d.getKey()));
|
joinDataModels.add(ontology.getDataModelMap().get(d.getKey()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return joinDataModels;
|
return joinDataModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -306,16 +306,6 @@ public class JoinRender extends Renderer {
|
|||||||
r.getMiddle(), tableView.getAlias() + "." + r.getRight()))
|
r.getMiddle(), tableView.getAlias() + "." + r.getRight()))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
matchJoinRelation.setJoinType(joinRelation.getJoinType());
|
matchJoinRelation.setJoinType(joinRelation.getJoinType());
|
||||||
// Added join condition judgment to solve the problem of join condition order
|
|
||||||
} else if (joinRelation.getLeft()
|
|
||||||
.equalsIgnoreCase(tableView.getDataModel().getName())
|
|
||||||
&& before.containsKey(joinRelation.getRight())) {
|
|
||||||
matchJoinRelation.setJoinCondition(joinRelation.getJoinCondition().stream()
|
|
||||||
.map(r -> Triple.of(
|
|
||||||
before.get(joinRelation.getRight()) + "." + r.getRight(),
|
|
||||||
r.getMiddle(), tableView.getAlias() + "." + r.getLeft()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
matchJoinRelation.setJoinType(joinRelation.getJoinType());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user