diff --git a/shadow-core/pom.xml b/shadow-core/pom.xml
index d2886bb7b394b70f3b35a4f1e41a7430508afd15..55b92eb2edfd72b8637f0937b61a65cc6c9f1001 100644
--- a/shadow-core/pom.xml
+++ b/shadow-core/pom.xml
@@ -31,5 +31,7 @@
shadow-core-rewrite
+ shadow-core-common
+ shadow-core-route
diff --git a/shadow-core/shadow-core-common/pom.xml b/shadow-core/shadow-core-common/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f20d76ed98ce50d27a22a1b5927a90331db2ed56
--- /dev/null
+++ b/shadow-core/shadow-core-common/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ shadow-core
+ org.apache.shardingsphere
+ 5.0.0-RC1-SNAPSHOT
+
+ 4.0.0
+
+ shadow-core-common
+ ${project.artifactId}
+
+
+
+ org.apache.shardingsphere
+ sharding-core-common
+ ${project.version}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-route
+ ${project.version}
+
+
+
diff --git a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowCondition.java b/shadow-core/shadow-core-common/src/main/java/org/apache/shardingsphere/shadow/common/condition/ShadowCondition.java
similarity index 98%
rename from shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowCondition.java
rename to shadow-core/shadow-core-common/src/main/java/org/apache/shardingsphere/shadow/common/condition/ShadowCondition.java
index 02d109f3257e4b019e89f14d219b96a58f937d56..fc48b8c68589e24ea618200317e2c3c448546df1 100644
--- a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowCondition.java
+++ b/shadow-core/shadow-core-common/src/main/java/org/apache/shardingsphere/shadow/common/condition/ShadowCondition.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.shadow.rewrite.condition;
+package org.apache.shardingsphere.shadow.common.condition;
import lombok.EqualsAndHashCode;
import lombok.Getter;
diff --git a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowConditionEngine.java b/shadow-core/shadow-core-common/src/main/java/org/apache/shardingsphere/shadow/common/condition/ShadowConditionEngine.java
similarity index 98%
rename from shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowConditionEngine.java
rename to shadow-core/shadow-core-common/src/main/java/org/apache/shardingsphere/shadow/common/condition/ShadowConditionEngine.java
index ca95ac25b8ad29369c55103b3bbab616ee90917d..911f8f011aaf9b1d80820c1a0695757107844ef3 100644
--- a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowConditionEngine.java
+++ b/shadow-core/shadow-core-common/src/main/java/org/apache/shardingsphere/shadow/common/condition/ShadowConditionEngine.java
@@ -15,11 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.shadow.rewrite.condition;
+package org.apache.shardingsphere.shadow.common.condition;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.core.rule.ShadowRule;
import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.sql.parser.binder.type.WhereAvailable;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.simple.SimpleExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.AndPredicate;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.PredicateSegment;
@@ -27,7 +28,6 @@ import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.WhereSegme
import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.value.PredicateBetweenRightValue;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.value.PredicateCompareRightValue;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.value.PredicateInRightValue;
-import org.apache.shardingsphere.sql.parser.binder.type.WhereAvailable;
import org.apache.shardingsphere.underlying.common.exception.ShardingSphereException;
import java.util.Collection;
diff --git a/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowConditionEngineTest.java b/shadow-core/shadow-core-common/src/test/java/org/apache/shardingsphere/shadow/common/condition/ShadowConditionEngineTest.java
similarity index 95%
rename from shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowConditionEngineTest.java
rename to shadow-core/shadow-core-common/src/test/java/org/apache/shardingsphere/shadow/common/condition/ShadowConditionEngineTest.java
index c3dad7e6ec31bdaa5b7cd14420e0c3d60a3ffffc..e764b8f81f8802daddc9385d72cf86798d92ebbf 100644
--- a/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/condition/ShadowConditionEngineTest.java
+++ b/shadow-core/shadow-core-common/src/test/java/org/apache/shardingsphere/shadow/common/condition/ShadowConditionEngineTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.shadow.rewrite.condition;
+package org.apache.shardingsphere.shadow.common.condition;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.simple.LiteralExpressionSegment;
import org.junit.Test;
diff --git a/shadow-core/shadow-core-rewrite/pom.xml b/shadow-core/shadow-core-rewrite/pom.xml
index 6ac2fcb885386f24ebd7ffd3dcff943ed93900c5..cb79dd58d9947b95cc656ff083614c6014684a72 100644
--- a/shadow-core/shadow-core-rewrite/pom.xml
+++ b/shadow-core/shadow-core-rewrite/pom.xml
@@ -34,6 +34,11 @@
sharding-core-common
${project.version}
+
+ org.apache.shardingsphere
+ shadow-core-common
+ ${project.version}
+
org.apache.shardingsphere
shardingsphere-sql-parser-binder
diff --git a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/ShadowJudgementEngine.java b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/ShadowJudgementEngine.java
index 2f6ff32a8806f91defd1ee6a01775845b06790e6..7bb02015223282ea38b5b58199cdd726332ccf04 100644
--- a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/ShadowJudgementEngine.java
+++ b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/ShadowJudgementEngine.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.shadow.rewrite.judgement;
/**
* Shadow judgement engine.
*/
+//TODO need to remove
public interface ShadowJudgementEngine {
/**
diff --git a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngine.java b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngine.java
index 536fabb610304c5790c9bee3399aeea798c18ad5..a0f92ad44dc66d4a71b57c7673e74d7794f1de9c 100644
--- a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngine.java
+++ b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngine.java
@@ -38,6 +38,7 @@ import java.util.Optional;
/**
* Shadow judgement engine for prepared.
*/
+//TODO need to remove
@RequiredArgsConstructor
public final class PreparedJudgementEngine implements ShadowJudgementEngine {
diff --git a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngine.java b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngine.java
index 0f625ffdabe7ae48b1d6c72d5df954228fe5d965..cf24773e8628d34cb9a3dbd55921df84e24fbe6d 100644
--- a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngine.java
+++ b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngine.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.shadow.rewrite.judgement.impl;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.core.rule.ShadowRule;
-import org.apache.shardingsphere.shadow.rewrite.condition.ShadowCondition;
-import org.apache.shardingsphere.shadow.rewrite.condition.ShadowConditionEngine;
+import org.apache.shardingsphere.shadow.common.condition.ShadowCondition;
+import org.apache.shardingsphere.shadow.common.condition.ShadowConditionEngine;
import org.apache.shardingsphere.shadow.rewrite.judgement.ShadowJudgementEngine;
import org.apache.shardingsphere.sql.parser.binder.segment.insert.values.InsertValueContext;
import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
@@ -35,6 +35,7 @@ import java.util.Optional;
/**
* Simple shadow judgement engine.
*/
+//TODO need to remove
@RequiredArgsConstructor
public final class SimpleJudgementEngine implements ShadowJudgementEngine {
diff --git a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowPredicateParameterRewriter.java b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowPredicateParameterRewriter.java
index fd02204f3b068335bc8592a4953a51a881521167..9819e22e0aa8f269c6a466217a2a04511fbe566a 100644
--- a/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowPredicateParameterRewriter.java
+++ b/shadow-core/shadow-core-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowPredicateParameterRewriter.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.shadow.rewrite.parameter.impl;
-import org.apache.shardingsphere.shadow.rewrite.condition.ShadowConditionEngine;
+import org.apache.shardingsphere.shadow.common.condition.ShadowConditionEngine;
import org.apache.shardingsphere.shadow.rewrite.parameter.ShadowParameterRewriter;
import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.underlying.rewrite.parameter.builder.ParameterBuilder;
diff --git a/shadow-core/shadow-core-route/pom.xml b/shadow-core/shadow-core-route/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3d2db538c5dbc76331cd2d3a6e3e94b6cd6a0c11
--- /dev/null
+++ b/shadow-core/shadow-core-route/pom.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+ shadow-core
+ org.apache.shardingsphere
+ 5.0.0-RC1-SNAPSHOT
+
+ 4.0.0
+
+ shadow-core-route
+ ${project.artifactId}
+
+
+
+ org.apache.shardingsphere
+ sharding-core-common
+ ${project.version}
+
+
+
+ org.apache.shardingsphere
+ shadow-core-common
+ ${project.version}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-route
+ ${project.version}
+
+
+
diff --git a/shadow-core/shadow-core-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowDataSourceRouter.java b/shadow-core/shadow-core-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowDataSourceRouter.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0a81b158f531650c16af8affd0f16e657e9e897
--- /dev/null
+++ b/shadow-core/shadow-core-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowDataSourceRouter.java
@@ -0,0 +1,43 @@
+/*
+ * 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.shadow.route.engine;
+
+/**
+ * Route decorator for shadow.
+ */
+public interface ShadowDataSourceRouter {
+
+ /**
+ * Judge whether SQL is shadow.
+ *
+ * @return SQL is shadow or not
+ */
+ boolean isShadowSQL();
+
+ /**
+ * Judge whether field is shadow.
+ * @param value the field
+ * @return field is shadow or not
+ */
+ default boolean isShadowField(final Object value) {
+ return (value instanceof Boolean && (Boolean) value)
+ || (value instanceof Integer && 1 == (Integer) value)
+ || (value instanceof String && Boolean.parseBoolean((String) value));
+ }
+
+}
diff --git a/shadow-core/shadow-core-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecorator.java b/shadow-core/shadow-core-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecorator.java
new file mode 100644
index 0000000000000000000000000000000000000000..ade55f0aaa13b2d4b92678edd64aa484a6aee29c
--- /dev/null
+++ b/shadow-core/shadow-core-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecorator.java
@@ -0,0 +1,107 @@
+/*
+ * 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.shadow.route.engine;
+
+import org.apache.shardingsphere.core.rule.ShadowRule;
+import org.apache.shardingsphere.shadow.route.engine.impl.PreparedShadowDataSourceRouter;
+import org.apache.shardingsphere.shadow.route.engine.impl.SimpleShadowDataSourceRouter;
+import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.sql.parser.sql.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.statement.dml.DMLStatement;
+import org.apache.shardingsphere.underlying.common.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.underlying.common.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.underlying.route.context.RouteContext;
+import org.apache.shardingsphere.underlying.route.context.RouteMapper;
+import org.apache.shardingsphere.underlying.route.context.RouteResult;
+import org.apache.shardingsphere.underlying.route.context.RouteUnit;
+import org.apache.shardingsphere.underlying.route.decorator.RouteDecorator;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Route decorator for shadow.
+ */
+public final class ShadowRouteDecorator implements RouteDecorator {
+
+ @Override
+ public RouteContext decorate(final RouteContext routeContext, final ShardingSphereMetaData metaData, final ShadowRule shadowRule, final ConfigurationProperties properties) {
+ return routeContext.getRouteResult().getRouteUnits().isEmpty() ? getRouteContext(routeContext, shadowRule) : getRouteContextWithRouteResult(routeContext, shadowRule);
+ }
+
+ private RouteContext getRouteContext(final RouteContext routeContext, final ShadowRule shadowRule) {
+ SQLStatementContext sqlStatementContext = routeContext.getSqlStatementContext();
+ SQLStatement sqlStatement = sqlStatementContext.getSqlStatement();
+ RouteResult routeResult = new RouteResult();
+ List