diff --git a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SimpleTableConverter.java b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SimpleTableConverter.java index cc04fc679c43c..a7e29139b076e 100644 --- a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SimpleTableConverter.java +++ b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SimpleTableConverter.java @@ -55,6 +55,10 @@ public static Optional convert(final SimpleTableSegment segment) { addOwnerNames(names, segment.getOwner().get()); } names.add(tableName.getIdentifier().getValue()); + if (segment.getDbLink().isPresent()) { + names.add(segment.getAt().get().getValue()); + names.add(segment.getDbLink().get().getValue()); + } SqlNode tableNameSQLNode = new SqlIdentifier(names, SqlParserPos.ZERO); if (segment.getAliasName().isPresent()) { SqlNode aliasSQLNode = new SqlIdentifier(segment.getAliasName().get(), SqlParserPos.ZERO); diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java index 18a08899175ce..d47b4cccc8dda 100644 --- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java +++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java @@ -121,6 +121,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression; import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.CaseWhenExpression; import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.CollateExpression; +import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment; import org.apache.shardingsphere.sql.parser.sql.dialect.segment.oracle.datetime.DatetimeExpression; import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment; import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionWithParamsSegment; @@ -458,6 +459,16 @@ public ASTNode visitUnpivotClause(final UnpivotClauseContext ctx) { @Override public ASTNode visitDmlTableClause(final DmlTableClauseContext ctx) { + if (null != ctx.AT_() && null != ctx.dbLink()) { + SimpleTableSegment result = new SimpleTableSegment(new TableNameSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), new IdentifierValue(ctx.tableName().name().getText()))); + if (null != ctx.tableName().owner()) { + result.setOwner( + new OwnerSegment(ctx.tableName().owner().start.getStartIndex(), ctx.tableName().owner().stop.getStopIndex(), (IdentifierValue) visit(ctx.tableName().owner().identifier()))); + } + result.setAt(new IdentifierValue(ctx.AT_().getText())); + result.setDbLink(new IdentifierValue(ctx.dbLink().identifier(0).getText())); + return result; + } return visit(ctx.tableName()); } diff --git a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/SimpleTableSegment.java b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/SimpleTableSegment.java index 88358eaeae038..fa16925e53ef8 100644 --- a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/SimpleTableSegment.java +++ b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/SimpleTableSegment.java @@ -46,6 +46,12 @@ public final class SimpleTableSegment implements TableSegment, OwnerAvailable { @Setter private PivotSegment pivot; + @Setter + private IdentifierValue dbLink; + + @Setter + private IdentifierValue at; + @Override public int getStartIndex() { if (null == owner) { @@ -64,6 +70,14 @@ public Optional getOwner() { return Optional.ofNullable(owner); } + public Optional getDbLink() { + return Optional.ofNullable(dbLink); + } + + public Optional getAt() { + return Optional.ofNullable(at); + } + @Override public Optional getAliasName() { return null == alias ? Optional.empty() : Optional.ofNullable(alias.getIdentifier().getValue()); diff --git a/test/it/optimizer/src/test/resources/converter/delete.xml b/test/it/optimizer/src/test/resources/converter/delete.xml index 331174393e624..f37d2046aaceb 100644 --- a/test/it/optimizer/src/test/resources/converter/delete.xml +++ b/test/it/optimizer/src/test/resources/converter/delete.xml @@ -42,4 +42,6 @@ + + diff --git a/test/it/parser/src/main/resources/case/dml/delete.xml b/test/it/parser/src/main/resources/case/dml/delete.xml index a717a5067bfd4..b1d9da931584f 100644 --- a/test/it/parser/src/main/resources/case/dml/delete.xml +++ b/test/it/parser/src/main/resources/case/dml/delete.xml @@ -611,7 +611,7 @@ - +