Merge branch 'tencentmusic:master' into master

This commit is contained in:
Jun Zhang
2024-12-09 22:13:50 +08:00
committed by GitHub
3 changed files with 24 additions and 6 deletions

View File

@@ -343,18 +343,25 @@ public class DataModelNode extends SemanticNode {
Map<String, Long> orders = new HashMap<>();
joinDataModelNames.add(baseDataModel.getName());
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()) {
if (joinDataModelNames.contains(joinRelation.getLeft())
&& joinDataModelNames.contains(joinRelation.getRight())) {
orders.put(joinRelation.getLeft(), 0L);
orders.put(joinRelation.getRight(), 1L);
joinTables.add(joinRelation.getLeft());
joinTables.add(joinRelation.getRight());
}
}
orders.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEach(d -> {
joinDataModels.add(ontology.getDataModelMap().get(d.getKey()));
});
for (String joinTable : joinTables) {
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()));
});
}
return joinDataModels;
}

View File

@@ -306,6 +306,16 @@ public class JoinRender extends Renderer {
r.getMiddle(), tableView.getAlias() + "." + r.getRight()))
.collect(Collectors.toList()));
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());
}
}
}

View File

@@ -64,6 +64,7 @@ const AgentsSection: React.FC<Props> = ({
}}
>
<Switch
key={agent.id}
size="small"
defaultChecked={status === 1}
onChange={(value) => {