From 93f48678a3104bafd7ed61819672dffa4c546086 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 26 Nov 2024 18:45:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E3=80=91=E5=8F=82=E6=95=B0=E5=8C=96=E6=8F=90=E7=A4=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=EF=BC=8C=E6=94=AF=E6=8C=81union?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/utils/SqlparserUtils.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java index 0dc588fe92..8cf92cb2a9 100644 --- a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java +++ b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java @@ -157,10 +157,22 @@ public class SqlparserUtils { for (Join join : joins) { FromItem rightItem = join.getRightItem(); if (rightItem instanceof ParenthesedSelect) { - PlainSelect selectBody = ((ParenthesedSelect) rightItem).getPlainSelect(); - Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectBody.toString(), dsType)); - PlainSelect subPlainSelect = ((PlainSelect) subSelectTmp.getSelectBody()); - ((ParenthesedSelect) rightItem).setSelect(subPlainSelect); + try { + PlainSelect selectBody = ((ParenthesedSelect) rightItem).getPlainSelect(); + Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectBody.toString(), dsType)); + PlainSelect subPlainSelect = ((PlainSelect) subSelectTmp.getSelectBody()); + ((ParenthesedSelect) rightItem).setSelect(subPlainSelect); + }catch ( Exception e ){ + SetOperationList select = ((ParenthesedSelect) rightItem).getSetOperationList(); + SetOperationList setOperationList = new SetOperationList(); + setOperationList.setSelects(new ArrayList<>()); + setOperationList.setOperations(select.getOperations()); + for (Select selectSelect : select.getSelects()) { + Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectSelect.toString(), dsType)); + setOperationList.getSelects().add(subSelectTmp); + } + ((ParenthesedSelect) rightItem).setSelect(setOperationList); + } if (dsType.equals(DatasourceConfiguration.DatasourceType.oracle.getType())) { rightItem.setAlias(new Alias(rightItem.getAlias().toString(), false)); } else {