This is an automated email from the ASF dual-hosted git repository. zhangliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new 1e10ad5e59f Add shardingsphere-infra-rewrite-mysql module (#35734) 1e10ad5e59f is described below commit 1e10ad5e59fe098f7ece9122171850cd86605ea4 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Tue Jun 17 18:29:22 2025 +0800 Add shardingsphere-infra-rewrite-mysql module (#35734) * Add shardingsphere-infra-rewrite-mysql module * Add shardingsphere-infra-rewrite-mysql module * Add shardingsphere-infra-rewrite-mysql module --- .../merge/dal/EncryptDALResultDecoratorTest.java | 5 +- .../show/EncryptShowColumnsMergedResultTest.java | 7 ++- .../statement/SQLStatementContextFactory.java | 12 ++--- .../type/dal/ShowColumnsStatementContext.java | 55 -------------------- .../type/dal/ShowIndexStatementContext.java | 55 -------------------- .../type/dal/ShowTableStatusStatementContext.java | 56 --------------------- .../type/dal/ShowTablesStatementContext.java | 56 --------------------- .../type/dal/ShowColumnsStatementContextTest.java | 54 -------------------- .../type/dal/ShowIndexStatementContextTest.java | 48 ------------------ .../DialectToBeRemovedSegmentsProvider.java} | 17 ++++--- .../generator/generic/RemoveTokenGenerator.java | 12 +++-- .../builder/DefaultTokenGeneratorBuilderTest.java | 12 ++--- .../doris => infra/rewrite/dialect/mysql}/pom.xml | 13 +++-- .../mysql/MySQLToBeRemovedSegmentsProvider.java | 58 ++++++++++++++++++++++ ...ator.generic.DialectToBeRemovedSegmentsProvider | 18 +++++++ infra/rewrite/{ => dialect}/pom.xml | 6 +-- infra/rewrite/pom.xml | 1 + jdbc-dialect/doris/pom.xml | 18 +++++++ jdbc-dialect/mariadb/pom.xml | 6 +++ jdbc-dialect/mysql/pom.xml | 6 +++ .../core/statement/dal/ShowColumnsStatement.java | 10 +++- .../core/statement/dal/ShowIndexStatement.java | 10 +++- proxy/dialect/doris/pom.xml | 18 +++++++ proxy/dialect/mariadb/pom.xml | 6 +++ proxy/dialect/mysql/pom.xml | 6 +++ test/it/rewriter/pom.xml | 12 +++++ 26 files changed, 211 insertions(+), 366 deletions(-) diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java index f80e45cc59a..66f65801bde 100644 --- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java +++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java @@ -23,7 +23,6 @@ import org.apache.shardingsphere.encrypt.rule.EncryptRule; import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ExplainStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowColumnsStatementContext; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.merge.result.MergedResult; import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; @@ -98,7 +97,7 @@ class EncryptDALResultDecoratorTest { } private SQLStatementContext getShowColumnsStatementContext() { - ShowColumnsStatementContext result = mock(ShowColumnsStatementContext.class, RETURNS_DEEP_STUBS); + SQLStatementContext result = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS); SimpleTableSegment simpleTableSegment = new SimpleTableSegment(new TableNameSegment(1, 7, new IdentifierValue("foo_tbl"))); when(result.getTablesContext().getSimpleTables()).thenReturn(Collections.singleton(simpleTableSegment)); when(result.getSqlStatement()).thenReturn(mock(ShowColumnsStatement.class)); @@ -106,7 +105,7 @@ class EncryptDALResultDecoratorTest { } private SQLStatementContext mockShowCreateTableStatementContext() { - CommonSQLStatementContext result = mock(CommonSQLStatementContext.class, RETURNS_DEEP_STUBS); + SQLStatementContext result = mock(CommonSQLStatementContext.class, RETURNS_DEEP_STUBS); when(result.getDatabaseType()).thenReturn(databaseType); SimpleTableSegment simpleTableSegment = new SimpleTableSegment(new TableNameSegment(1, 7, new IdentifierValue("foo_tbl"))); when(result.getTablesContext().getSimpleTables()).thenReturn(Collections.singleton(simpleTableSegment)); diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowColumnsMergedResultTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowColumnsMergedResultTest.java index dafe62f9fe2..baf3c752d34 100644 --- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowColumnsMergedResultTest.java +++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowColumnsMergedResultTest.java @@ -21,7 +21,6 @@ import org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptSQLE import org.apache.shardingsphere.encrypt.rule.EncryptRule; import org.apache.shardingsphere.encrypt.rule.table.EncryptTable; import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowColumnsStatementContext; import org.apache.shardingsphere.infra.merge.result.MergedResult; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment; @@ -152,8 +151,8 @@ class EncryptShowColumnsMergedResultTest { } private EncryptShowColumnsMergedResult createMergedResult(final MergedResult mergedResult, final EncryptRule rule) { - ShowColumnsStatementContext showColumnsStatementContext = mock(ShowColumnsStatementContext.class, RETURNS_DEEP_STUBS); - when(showColumnsStatementContext.getTablesContext().getSimpleTables()).thenReturn(Collections.singleton(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_encrypt"))))); - return new EncryptShowColumnsMergedResult(mergedResult, showColumnsStatementContext, rule); + SQLStatementContext sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS); + when(sqlStatementContext.getTablesContext().getSimpleTables()).thenReturn(Collections.singleton(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_encrypt"))))); + return new EncryptShowColumnsMergedResult(mergedResult, sqlStatementContext, rule); } } diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java index bb27a9608b0..cddfac3d9bb 100644 --- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java +++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java @@ -21,10 +21,6 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.apache.shardingsphere.infra.binder.context.provider.DialectCommonSQLStatementContextWarpProvider; import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ExplainStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowColumnsStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowIndexStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowTableStatusStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowTablesStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.AlterIndexStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.AlterTableStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.AlterViewStatementContext; @@ -231,16 +227,16 @@ public final class SQLStatementContextFactory { return new ExplainStatementContext(metaData, databaseType, (ExplainStatement) sqlStatement, params, currentDatabaseName); } if (sqlStatement instanceof ShowColumnsStatement) { - return new ShowColumnsStatementContext(databaseType, (ShowColumnsStatement) sqlStatement); + return new CommonSQLStatementContext(databaseType, sqlStatement); } if (sqlStatement instanceof ShowTablesStatement) { - return new ShowTablesStatementContext(databaseType, (ShowTablesStatement) sqlStatement); + return new CommonSQLStatementContext(databaseType, sqlStatement); } if (sqlStatement instanceof ShowTableStatusStatement) { - return new ShowTableStatusStatementContext(databaseType, (ShowTableStatusStatement) sqlStatement); + return new CommonSQLStatementContext(databaseType, sqlStatement); } if (sqlStatement instanceof ShowIndexStatement) { - return new ShowIndexStatementContext(databaseType, (ShowIndexStatement) sqlStatement); + return new CommonSQLStatementContext(databaseType, sqlStatement); } if (sqlStatement instanceof AnalyzeTableStatement) { return new CommonSQLStatementContext(databaseType, sqlStatement); diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowColumnsStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowColumnsStatementContext.java deleted file mode 100644 index 53a11893308..00000000000 --- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowColumnsStatementContext.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.binder.context.statement.type.dal; - -import lombok.Getter; -import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext; -import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; -import org.apache.shardingsphere.infra.binder.context.type.RemoveAvailable; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment; -import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowColumnsStatement; - -import java.util.Collection; -import java.util.LinkedList; - -/** - * Show columns statement context. - */ -@Getter -public final class ShowColumnsStatementContext implements SQLStatementContext, RemoveAvailable { - - private final DatabaseType databaseType; - - private final ShowColumnsStatement sqlStatement; - - private final TablesContext tablesContext; - - public ShowColumnsStatementContext(final DatabaseType databaseType, final ShowColumnsStatement sqlStatement) { - this.databaseType = databaseType; - this.sqlStatement = sqlStatement; - tablesContext = new TablesContext(sqlStatement.getTable()); - } - - @Override - public Collection<SQLSegment> getRemoveSegments() { - Collection<SQLSegment> result = new LinkedList<>(); - sqlStatement.getFromDatabase().ifPresent(result::add); - return result; - } -} diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowIndexStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowIndexStatementContext.java deleted file mode 100644 index 73f0bfebf27..00000000000 --- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowIndexStatementContext.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.binder.context.statement.type.dal; - -import lombok.Getter; -import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext; -import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; -import org.apache.shardingsphere.infra.binder.context.type.RemoveAvailable; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment; -import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowIndexStatement; - -import java.util.Collection; -import java.util.LinkedList; - -/** - * Show index statement context. - */ -@Getter -public final class ShowIndexStatementContext implements SQLStatementContext, RemoveAvailable { - - private final DatabaseType databaseType; - - private final ShowIndexStatement sqlStatement; - - private final TablesContext tablesContext; - - public ShowIndexStatementContext(final DatabaseType databaseType, final ShowIndexStatement sqlStatement) { - this.databaseType = databaseType; - this.sqlStatement = sqlStatement; - tablesContext = new TablesContext(sqlStatement.getTable()); - } - - @Override - public Collection<SQLSegment> getRemoveSegments() { - Collection<SQLSegment> result = new LinkedList<>(); - sqlStatement.getFromDatabase().ifPresent(result::add); - return result; - } -} diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowTableStatusStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowTableStatusStatementContext.java deleted file mode 100644 index b9153518384..00000000000 --- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowTableStatusStatementContext.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.binder.context.statement.type.dal; - -import lombok.Getter; -import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext; -import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; -import org.apache.shardingsphere.infra.binder.context.type.RemoveAvailable; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment; -import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTableStatusStatement; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; - -/** - * Show table status statement context. - */ -@Getter -public final class ShowTableStatusStatementContext implements SQLStatementContext, RemoveAvailable { - - private final DatabaseType databaseType; - - private final ShowTableStatusStatement sqlStatement; - - private final TablesContext tablesContext; - - public ShowTableStatusStatementContext(final DatabaseType databaseType, final ShowTableStatusStatement sqlStatement) { - this.databaseType = databaseType; - this.sqlStatement = sqlStatement; - tablesContext = new TablesContext(Collections.emptyList()); - } - - @Override - public Collection<SQLSegment> getRemoveSegments() { - Collection<SQLSegment> result = new LinkedList<>(); - sqlStatement.getFromDatabase().ifPresent(result::add); - return result; - } -} diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowTablesStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowTablesStatementContext.java deleted file mode 100644 index cf71d4e36eb..00000000000 --- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowTablesStatementContext.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.binder.context.statement.type.dal; - -import lombok.Getter; -import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext; -import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; -import org.apache.shardingsphere.infra.binder.context.type.RemoveAvailable; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment; -import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTablesStatement; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; - -/** - * Show tables statement context. - */ -@Getter -public final class ShowTablesStatementContext implements SQLStatementContext, RemoveAvailable { - - private final DatabaseType databaseType; - - private final ShowTablesStatement sqlStatement; - - private final TablesContext tablesContext; - - public ShowTablesStatementContext(final DatabaseType databaseType, final ShowTablesStatement sqlStatement) { - this.databaseType = databaseType; - this.sqlStatement = sqlStatement; - tablesContext = new TablesContext(Collections.emptyList()); - } - - @Override - public Collection<SQLSegment> getRemoveSegments() { - Collection<SQLSegment> result = new LinkedList<>(); - sqlStatement.getFromDatabase().ifPresent(result::add); - return result; - } -} diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowColumnsStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowColumnsStatementContextTest.java deleted file mode 100644 index 7bc292d2185..00000000000 --- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowColumnsStatementContextTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.binder.context.statement.type.dal; - -import org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment; -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.DatabaseSegment; -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo; -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment; -import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowColumnsStatement; -import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class ShowColumnsStatementContextTest { - - @Test - void assertNewInstance() { - ShowColumnsStatement sqlStatement = mock(ShowColumnsStatement.class); - TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")); - tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema"))); - when(sqlStatement.getTable()).thenReturn(new SimpleTableSegment(tableNameSegment)); - FromDatabaseSegment fromDatabase = new FromDatabaseSegment(0, new DatabaseSegment(0, 0, new IdentifierValue("foo_db"))); - when(sqlStatement.getFromDatabase()).thenReturn(Optional.of(fromDatabase)); - ShowColumnsStatementContext actual = new ShowColumnsStatementContext(mock(), sqlStatement); - assertThat(actual.getSqlStatement(), is(sqlStatement)); - assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()), - is(Collections.singletonList("foo_tbl"))); - assertThat(actual.getRemoveSegments(), is(Collections.singletonList(fromDatabase))); - } -} diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowIndexStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowIndexStatementContextTest.java deleted file mode 100644 index db571903f57..00000000000 --- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ShowIndexStatementContextTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.binder.context.statement.type.dal; - -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo; -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; -import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment; -import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowIndexStatement; -import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.stream.Collectors; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class ShowIndexStatementContextTest { - - @Test - void assertNewInstance() { - ShowIndexStatement sqlStatement = mock(ShowIndexStatement.class); - TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")); - tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema"))); - when(sqlStatement.getTable()).thenReturn(new SimpleTableSegment(tableNameSegment)); - ShowIndexStatementContext actual = new ShowIndexStatementContext(mock(), sqlStatement); - assertThat(actual.getSqlStatement(), is(sqlStatement)); - assertThat(actual.getTablesContext().getSimpleTables().stream() - .map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()), is(Collections.singletonList("foo_tbl"))); - } -} diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/type/RemoveAvailable.java b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/DialectToBeRemovedSegmentsProvider.java similarity index 59% rename from infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/type/RemoveAvailable.java rename to infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/DialectToBeRemovedSegmentsProvider.java index a4af0050974..126dc31fd77 100644 --- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/type/RemoveAvailable.java +++ b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/DialectToBeRemovedSegmentsProvider.java @@ -15,21 +15,26 @@ * limitations under the License. */ -package org.apache.shardingsphere.infra.binder.context.type; +package org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic; +import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPI; +import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI; import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment; +import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement; import java.util.Collection; /** - * Remove available. + * Dialect to be removed segments provider. */ -public interface RemoveAvailable { +@SingletonSPI +public interface DialectToBeRemovedSegmentsProvider extends DatabaseTypedSPI { /** - * Get remove segments. + * Get to be removed SQL segments. * - * @return remove segments + * @param sqlStatement SQL statement + * @return to be removed SQL segments */ - Collection<SQLSegment> getRemoveSegments(); + Collection<SQLSegment> getToBeRemovedSQLSegments(SQLStatement sqlStatement); } diff --git a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/RemoveTokenGenerator.java b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/RemoveTokenGenerator.java index cc38083878e..38004ab575c 100644 --- a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/RemoveTokenGenerator.java +++ b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/generic/RemoveTokenGenerator.java @@ -19,8 +19,8 @@ package org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.gener import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; import org.apache.shardingsphere.infra.binder.context.type.IndexAvailable; -import org.apache.shardingsphere.infra.binder.context.type.RemoveAvailable; import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.DialectDatabaseMetaData; +import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry; import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.CollectionSQLTokenGenerator; @@ -32,6 +32,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.Owner import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.stream.Collectors; @@ -42,7 +43,8 @@ public final class RemoveTokenGenerator implements CollectionSQLTokenGenerator<S @Override public boolean isGenerateSQLToken(final SQLStatementContext sqlStatementContext) { - if (sqlStatementContext instanceof RemoveAvailable && !((RemoveAvailable) sqlStatementContext).getRemoveSegments().isEmpty()) { + if (DatabaseTypedSPILoader.findService(DialectToBeRemovedSegmentsProvider.class, sqlStatementContext.getDatabaseType()) + .map(optional -> !optional.getToBeRemovedSQLSegments(sqlStatementContext.getSqlStatement()).isEmpty()).orElse(false)) { return true; } if (!sqlStatementContext.getTablesContext().getSimpleTables().isEmpty()) { @@ -54,8 +56,10 @@ public final class RemoveTokenGenerator implements CollectionSQLTokenGenerator<S @Override public Collection<SQLToken> generateSQLTokens(final SQLStatementContext sqlStatementContext) { Collection<SQLToken> result = new LinkedList<>(); - if (sqlStatementContext instanceof RemoveAvailable && !((RemoveAvailable) sqlStatementContext).getRemoveSegments().isEmpty()) { - result.addAll(generateRemoveAvailableSQLTokens(((RemoveAvailable) sqlStatementContext).getRemoveSegments())); + Collection<SQLSegment> toBeRemovedSQLSegments = DatabaseTypedSPILoader.findService(DialectToBeRemovedSegmentsProvider.class, sqlStatementContext.getDatabaseType()) + .map(optional -> optional.getToBeRemovedSQLSegments(sqlStatementContext.getSqlStatement())).orElse(Collections.emptyList()); + if (!toBeRemovedSQLSegments.isEmpty()) { + result.addAll(generateRemoveAvailableSQLTokens(toBeRemovedSQLSegments)); } if (!sqlStatementContext.getTablesContext().getSimpleTables().isEmpty()) { result.addAll(generateTableAvailableSQLTokens(sqlStatementContext, sqlStatementContext.getDatabaseType())); diff --git a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java index d7156950c3b..cd8fa83ced3 100644 --- a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java +++ b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java @@ -17,9 +17,8 @@ package org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.builder; +import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowColumnsStatementContext; -import org.apache.shardingsphere.infra.binder.context.statement.type.dal.ShowTableStatusStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext; import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.SQLTokenGenerator; import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.RemoveTokenGenerator; @@ -38,10 +37,8 @@ import static org.mockito.Mockito.when; class DefaultTokenGeneratorBuilderTest { @Test - void assertGetSQLTokenGeneratorsWithShowTableStatus() { - ShowTableStatusStatementContext sqlStatementContext = mock(ShowTableStatusStatementContext.class, RETURNS_DEEP_STUBS); - when(sqlStatementContext.getRemoveSegments().isEmpty()).thenReturn(false); - assertGetSQLTokenGenerators(sqlStatementContext); + void assertGetSQLTokenGeneratorsWithCommonSQLStatementContext() { + assertGetSQLTokenGenerators(mock(CommonSQLStatementContext.class, RETURNS_DEEP_STUBS)); } @Test @@ -53,8 +50,7 @@ class DefaultTokenGeneratorBuilderTest { @Test void assertGetSQLTokenGeneratorsWithShowColumns() { - ShowColumnsStatementContext sqlStatementContext = mock(ShowColumnsStatementContext.class, RETURNS_DEEP_STUBS); - when(sqlStatementContext.getRemoveSegments().isEmpty()).thenReturn(false); + SQLStatementContext sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS); when(sqlStatementContext.getTablesContext().getDatabaseName().isPresent()).thenReturn(true); assertGetSQLTokenGenerators(sqlStatementContext); } diff --git a/proxy/dialect/doris/pom.xml b/infra/rewrite/dialect/mysql/pom.xml similarity index 76% copy from proxy/dialect/doris/pom.xml copy to infra/rewrite/dialect/mysql/pom.xml index ccd520e37b1..88028724dea 100644 --- a/proxy/dialect/doris/pom.xml +++ b/infra/rewrite/dialect/mysql/pom.xml @@ -20,18 +20,23 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-proxy-dialect</artifactId> + <artifactId>shardingsphere-infra-rewrite-dialect</artifactId> <version>5.5.3-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-proxy-dialect-doris</artifactId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> <name>${project.artifactId}</name> <dependencies> <dependency> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-parser-sql-doris</artifactId> + <artifactId>shardingsphere-infra-rewrite-core</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-parser-sql-statement-mysql</artifactId> <version>${project.version}</version> - <scope>runtime</scope> </dependency> </dependencies> </project> diff --git a/infra/rewrite/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProvider.java b/infra/rewrite/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProvider.java new file mode 100644 index 00000000000..bbc62f4a9bc --- /dev/null +++ b/infra/rewrite/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProvider.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.infra.rewrite.mysql; + +import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.DialectToBeRemovedSegmentsProvider; +import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment; +import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement; +import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowColumnsStatement; +import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowIndexStatement; +import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTableStatusStatement; +import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTablesStatement; + +import java.util.Collection; +import java.util.LinkedList; + +/** + * Dialect to be removed segments provider. + */ +public final class MySQLToBeRemovedSegmentsProvider implements DialectToBeRemovedSegmentsProvider { + + @Override + public Collection<SQLSegment> getToBeRemovedSQLSegments(final SQLStatement sqlStatement) { + Collection<SQLSegment> result = new LinkedList<>(); + if (sqlStatement instanceof ShowTablesStatement) { + ((ShowTablesStatement) sqlStatement).getFromDatabase().ifPresent(result::add); + } + if (sqlStatement instanceof ShowColumnsStatement) { + ((ShowColumnsStatement) sqlStatement).getFromDatabase().ifPresent(result::add); + } + if (sqlStatement instanceof ShowIndexStatement) { + ((ShowIndexStatement) sqlStatement).getFromDatabase().ifPresent(result::add); + } + if (sqlStatement instanceof ShowTableStatusStatement) { + ((ShowTableStatusStatement) sqlStatement).getFromDatabase().ifPresent(result::add); + } + return result; + } + + @Override + public String getDatabaseType() { + return "MySQL"; + } +} diff --git a/infra/rewrite/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.DialectToBeRemovedSegmentsProvider b/infra/rewrite/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.DialectToBeRemovedSegmentsProvider new file mode 100644 index 00000000000..1b28047c76f --- /dev/null +++ b/infra/rewrite/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.DialectToBeRemovedSegmentsProvider @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +org.apache.shardingsphere.infra.rewrite.mysql.MySQLToBeRemovedSegmentsProvider diff --git a/infra/rewrite/pom.xml b/infra/rewrite/dialect/pom.xml similarity index 89% copy from infra/rewrite/pom.xml copy to infra/rewrite/dialect/pom.xml index b0dabcb66dd..d7fd975bf82 100644 --- a/infra/rewrite/pom.xml +++ b/infra/rewrite/dialect/pom.xml @@ -20,14 +20,14 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-infra</artifactId> + <artifactId>shardingsphere-infra-rewrite</artifactId> <version>5.5.3-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-infra-rewrite</artifactId> + <artifactId>shardingsphere-infra-rewrite-dialect</artifactId> <packaging>pom</packaging> <name>${project.artifactId}</name> <modules> - <module>core</module> + <module>mysql</module> </modules> </project> diff --git a/infra/rewrite/pom.xml b/infra/rewrite/pom.xml index b0dabcb66dd..5d1d28be12e 100644 --- a/infra/rewrite/pom.xml +++ b/infra/rewrite/pom.xml @@ -29,5 +29,6 @@ <modules> <module>core</module> + <module>dialect</module> </modules> </project> diff --git a/jdbc-dialect/doris/pom.xml b/jdbc-dialect/doris/pom.xml index aeea472e284..ca1b678dc60 100644 --- a/jdbc-dialect/doris/pom.xml +++ b/jdbc-dialect/doris/pom.xml @@ -33,5 +33,23 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-binder-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-route-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> </dependencies> </project> diff --git a/jdbc-dialect/mariadb/pom.xml b/jdbc-dialect/mariadb/pom.xml index 958d09934c4..5d48e8b5fe3 100644 --- a/jdbc-dialect/mariadb/pom.xml +++ b/jdbc-dialect/mariadb/pom.xml @@ -51,5 +51,11 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> </dependencies> </project> diff --git a/jdbc-dialect/mysql/pom.xml b/jdbc-dialect/mysql/pom.xml index 54ca25b33c8..fd95f9468e0 100644 --- a/jdbc-dialect/mysql/pom.xml +++ b/jdbc-dialect/mysql/pom.xml @@ -45,5 +45,11 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> </dependencies> </project> diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowColumnsStatement.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowColumnsStatement.java index d6b6d4c6a0f..a4119c86c4b 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowColumnsStatement.java +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowColumnsStatement.java @@ -24,7 +24,10 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilte import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.statement.core.statement.AbstractSQLStatement; import org.apache.shardingsphere.sql.parser.statement.core.statement.FromDatabaseAvailable; +import org.apache.shardingsphere.sql.parser.statement.core.statement.TableAvailable; +import java.util.Collection; +import java.util.Collections; import java.util.Optional; /** @@ -32,7 +35,7 @@ import java.util.Optional; */ @RequiredArgsConstructor @Getter -public final class ShowColumnsStatement extends AbstractSQLStatement implements DALStatement, FromDatabaseAvailable { +public final class ShowColumnsStatement extends AbstractSQLStatement implements DALStatement, TableAvailable, FromDatabaseAvailable { private final SimpleTableSegment table; @@ -40,6 +43,11 @@ public final class ShowColumnsStatement extends AbstractSQLStatement implements private final ShowFilterSegment filter; + @Override + public Collection<SimpleTableSegment> getTables() { + return Collections.singleton(table); + } + @Override public Optional<FromDatabaseSegment> getFromDatabase() { return Optional.ofNullable(fromDatabase); diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowIndexStatement.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowIndexStatement.java index ae000d66e9c..b422f7d0729 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowIndexStatement.java +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ShowIndexStatement.java @@ -23,7 +23,10 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatab import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.statement.core.statement.AbstractSQLStatement; import org.apache.shardingsphere.sql.parser.statement.core.statement.FromDatabaseAvailable; +import org.apache.shardingsphere.sql.parser.statement.core.statement.TableAvailable; +import java.util.Collection; +import java.util.Collections; import java.util.Optional; /** @@ -31,12 +34,17 @@ import java.util.Optional; */ @RequiredArgsConstructor @Getter -public final class ShowIndexStatement extends AbstractSQLStatement implements DALStatement, FromDatabaseAvailable { +public final class ShowIndexStatement extends AbstractSQLStatement implements DALStatement, TableAvailable, FromDatabaseAvailable { private final SimpleTableSegment table; private final FromDatabaseSegment fromDatabase; + @Override + public Collection<SimpleTableSegment> getTables() { + return Collections.singleton(table); + } + @Override public Optional<FromDatabaseSegment> getFromDatabase() { return Optional.ofNullable(fromDatabase); diff --git a/proxy/dialect/doris/pom.xml b/proxy/dialect/doris/pom.xml index ccd520e37b1..95de38eb63b 100644 --- a/proxy/dialect/doris/pom.xml +++ b/proxy/dialect/doris/pom.xml @@ -33,5 +33,23 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-binder-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-route-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> </dependencies> </project> diff --git a/proxy/dialect/mariadb/pom.xml b/proxy/dialect/mariadb/pom.xml index b6a8dffa6c2..f65110aed10 100644 --- a/proxy/dialect/mariadb/pom.xml +++ b/proxy/dialect/mariadb/pom.xml @@ -51,6 +51,12 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-mysql-protocol</artifactId> diff --git a/proxy/dialect/mysql/pom.xml b/proxy/dialect/mysql/pom.xml index ceee171e2f8..b7bbe42db7c 100644 --- a/proxy/dialect/mysql/pom.xml +++ b/proxy/dialect/mysql/pom.xml @@ -45,6 +45,12 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-mysql-protocol</artifactId> diff --git a/test/it/rewriter/pom.xml b/test/it/rewriter/pom.xml index 0849701be87..56b1f725ec1 100644 --- a/test/it/rewriter/pom.xml +++ b/test/it/rewriter/pom.xml @@ -80,6 +80,18 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-route-mysql</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-infra-rewrite-mysql</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-parser-sql-postgresql</artifactId>