mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 04:27:39 +00:00
[improvement][headless] Fix the issue with the query when using the with clause along with a join (#1779)
This commit is contained in:
@@ -439,16 +439,18 @@ public class SqlReplaceHelper {
|
|||||||
private static void replaceJoins(PlainSelect plainSelect, String tableName,
|
private static void replaceJoins(PlainSelect plainSelect, String tableName,
|
||||||
List<String> withNameList) {
|
List<String> withNameList) {
|
||||||
List<Join> joins = plainSelect.getJoins();
|
List<Join> joins = plainSelect.getJoins();
|
||||||
|
TableNameReplaceVisitor fromItemVisitor =
|
||||||
|
new TableNameReplaceVisitor(tableName, new HashSet<>(withNameList));
|
||||||
if (!CollectionUtils.isEmpty(joins)) {
|
if (!CollectionUtils.isEmpty(joins)) {
|
||||||
for (Join join : joins) {
|
for (Join join : joins) {
|
||||||
if (join.getRightItem() instanceof ParenthesedFromItem) {
|
if (join.getRightItem() instanceof ParenthesedFromItem) {
|
||||||
List<PlainSelect> subPlainSelects = SqlSelectHelper.getPlainSelects(
|
List<PlainSelect> subPlainSelects = SqlSelectHelper.getPlainSelects(
|
||||||
Collections.singletonList((PlainSelect) join.getRightItem()));
|
Collections.singletonList((PlainSelect) join.getRightItem()));
|
||||||
subPlainSelects.forEach(subPlainSelect -> subPlainSelect.getFromItem().accept(
|
subPlainSelects.forEach(subPlainSelect -> {
|
||||||
new TableNameReplaceVisitor(tableName, new HashSet<>(withNameList))));
|
subPlainSelect.getFromItem().accept(fromItemVisitor);
|
||||||
|
});
|
||||||
} else if (join.getRightItem() instanceof Table) {
|
} else if (join.getRightItem() instanceof Table) {
|
||||||
Table table = (Table) join.getRightItem();
|
join.getRightItem().accept(fromItemVisitor);
|
||||||
table.setName(tableName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user