[improvement][headless]Support s2sql with union all statements.

This commit is contained in:
jerryjzhang
2024-12-27 11:25:33 +08:00
parent ce9ae1c0c1
commit ade03627ce
6 changed files with 154 additions and 18 deletions

View File

@@ -229,6 +229,26 @@ public class SqlReplaceHelper {
orderByElement.accept(new OrderByReplaceVisitor(fieldNameMap, exactReplace));
}
}
List<Select> selects = operationList.getSelects();
if (!CollectionUtils.isEmpty(selects)) {
for (Select select : selects) {
if (select instanceof PlainSelect) {
replaceFieldsInPlainOneSelect(fieldNameMap, exactReplace, (PlainSelect) select);
}
}
}
List<WithItem> withItems = operationList.getWithItemsList();
if (!CollectionUtils.isEmpty(withItems)) {
for (WithItem withItem : withItems) {
Select select = withItem.getSelect();
if (select instanceof PlainSelect) {
replaceFieldsInPlainOneSelect(fieldNameMap, exactReplace, (PlainSelect) select);
} else if (select instanceof ParenthesedSelect) {
replaceFieldsInPlainOneSelect(fieldNameMap, exactReplace,
select.getPlainSelect());
}
}
}
}
public static String replaceFunction(String sql, Map<String, String> functionMap) {
@@ -610,6 +630,25 @@ public class SqlReplaceHelper {
plainSelectList.add(subPlainSelect);
});
}
List<Select> selects = setOperationList.getSelects();
if (!CollectionUtils.isEmpty(selects)) {
for (Select select : selects) {
if (select instanceof PlainSelect) {
plainSelectList.add((PlainSelect) select);
}
}
}
List<WithItem> withItems = setOperationList.getWithItemsList();
if (!CollectionUtils.isEmpty(withItems)) {
for (WithItem withItem : withItems) {
Select select = withItem.getSelect();
if (select instanceof PlainSelect) {
plainSelectList.add((PlainSelect) select);
} else if (select instanceof ParenthesedSelect) {
plainSelectList.add(select.getPlainSelect());
}
}
}
} else {
return sql;
}