You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/10/21 11:03:51 UTC

[shardingsphere] branch master updated: Optimize shadow router (#13205)

This is an automated email from the ASF dual-hosted git repository.

panjuan 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 af404d1  Optimize shadow router (#13205)
af404d1 is described below

commit af404d10ccd1f724686e6d7943685439f8972721
Author: gin <ja...@163.com>
AuthorDate: Thu Oct 21 19:03:09 2021 +0800

    Optimize shadow router (#13205)
    
    * Optimize shadow route engine, add sql note parse switch judgment.
    
    * Fix shadow ut.
    
    * Fix shadow determine condition.
---
 .../shadow/route/ShadowSQLRouter.java              |  6 +--
 .../shadow/route/engine/ShadowRouteEngine.java     |  4 +-
 .../engine/determiner/ShadowDeterminerFactory.java |  4 +-
 .../dml/AbstractShadowDMLStatementRouteEngine.java | 34 ++++++++++------
 .../dml/ShadowDeleteStatementRoutingEngine.java    | 10 +----
 .../dml/ShadowInsertStatementRoutingEngine.java    |  3 +-
 .../dml/ShadowSelectStatementRoutingEngine.java    | 10 +----
 .../dml/ShadowUpdateStatementRoutingEngine.java    | 10 +----
 .../impl/ShadowNonDMLStatementRoutingEngine.java   | 30 +++++++++-----
 .../shadow/route/engine/util/ShadowExtractor.java  | 13 ++++++
 .../shardingsphere/shadow/rule/ShadowRule.java     | 47 +++++-----------------
 .../ColumnShadowAlgorithmDeterminerTest.java       |  6 +--
 .../NoteShadowAlgorithmDeterminerTest.java         | 10 +----
 .../ShadowDeleteStatementRoutingEngineTest.java    |  6 ++-
 .../ShadowInsertStatementRoutingEngineTest.java    |  6 ++-
 .../ShadowSelectStatementRoutingEngineTest.java    |  6 ++-
 .../ShadowUpdateStatementRoutingEngineTest.java    |  6 ++-
 17 files changed, 105 insertions(+), 106 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
index 3f1c5f7..f7b8370 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
@@ -41,12 +41,12 @@ public final class ShadowSQLRouter implements SQLRouter<ShadowRule> {
     public void decorateRouteContext(final RouteContext routeContext,
                                      final LogicSQL logicSQL, final ShardingSphereMetaData metaData, final ShadowRule rule, final ConfigurationProperties props) {
         if (rule.isEnable()) {
-            doShadowDecorate(routeContext, logicSQL, rule);
+            doShadowDecorate(routeContext, logicSQL, rule, props);
         }
     }
     
-    private void doShadowDecorate(final RouteContext routeContext, final LogicSQL logicSQL, final ShadowRule rule) {
-        ShadowRouteEngineFactory.newInstance(logicSQL).route(routeContext, rule);
+    private void doShadowDecorate(final RouteContext routeContext, final LogicSQL logicSQL, final ShadowRule rule, final ConfigurationProperties props) {
+        ShadowRouteEngineFactory.newInstance(logicSQL).route(routeContext, rule, props);
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java
index cdefe2f..53bcba4 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.shadow.route.engine;
 
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
 
@@ -30,6 +31,7 @@ public interface ShadowRouteEngine {
      *
      * @param routeContext route context
      * @param shadowRule shadow rule
+     * @param props configuration properties
      */
-    void route(RouteContext routeContext, ShadowRule shadowRule);
+    void route(RouteContext routeContext, ShadowRule shadowRule, ConfigurationProperties props);
 }
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/ShadowDeterminerFactory.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/ShadowDeterminerFactory.java
index 72a968f..6d8e2c0 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/ShadowDeterminerFactory.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/ShadowDeterminerFactory.java
@@ -33,7 +33,7 @@ public final class ShadowDeterminerFactory {
     /**
      * Create new instance of Shadow algorithm determiner.
      *
-     * @param noteShadowAlgorithm note shadow algorithm.
+     * @param noteShadowAlgorithm note shadow algorithm
      * @return new instance of Shadow algorithm determiner
      */
     public static ShadowAlgorithmDeterminer newInstance(final NoteShadowAlgorithm<Comparable<?>> noteShadowAlgorithm) {
@@ -43,7 +43,7 @@ public final class ShadowDeterminerFactory {
     /**
      * Create new instance of Shadow algorithm determiner.
      *
-     * @param columnShadowAlgorithm column shadow algorithm.
+     * @param columnShadowAlgorithm column shadow algorithm
      * @return new instance of Shadow algorithm determiner
      */
     public static ShadowAlgorithmDeterminer newInstance(final ColumnShadowAlgorithm<Comparable<?>> columnShadowAlgorithm) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/AbstractShadowDMLStatementRouteEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/AbstractShadowDMLStatementRouteEngine.java
index b1e80bc..4c8a5b1 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/AbstractShadowDMLStatementRouteEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/AbstractShadowDMLStatementRouteEngine.java
@@ -18,6 +18,8 @@
 package org.apache.shardingsphere.shadow.route.engine.dml;
 
 import lombok.Getter;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -47,32 +49,33 @@ public abstract class AbstractShadowDMLStatementRouteEngine implements ShadowRou
     private final Map<String, String> tableAliasNameMappings = new LinkedHashMap<>();
     
     @Override
-    public void route(final RouteContext routeContext, final ShadowRule shadowRule) {
-        findShadowDataSourceMappings(shadowRule).ifPresent(shadowDataSourceMappings -> shadowDMLStatementRouteDecorate(routeContext, shadowDataSourceMappings));
+    public void route(final RouteContext routeContext, final ShadowRule shadowRule, final ConfigurationProperties props) {
+        findShadowDataSourceMappings(shadowRule, props).ifPresent(shadowDataSourceMappings -> shadowDMLStatementRouteDecorate(routeContext, shadowDataSourceMappings));
     }
     
-    private Optional<Map<String, String>> findShadowDataSourceMappings(final ShadowRule shadowRule) {
+    private Optional<Map<String, String>> findShadowDataSourceMappings(final ShadowRule shadowRule, final ConfigurationProperties props) {
         Collection<String> relatedShadowTables = getRelatedShadowTables(getAllTables(), shadowRule);
+        boolean sqlCommentParseEnabled = Boolean.parseBoolean(String.valueOf(props.getProps().get(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey())));
         ShadowOperationType shadowOperationType = getShadowOperationType();
         for (String each : relatedShadowTables) {
-            if (isShadowTable(each, shadowRule, shadowOperationType)) {
+            if (isShadowTable(each, shadowRule, shadowOperationType, sqlCommentParseEnabled)) {
                 return shadowRule.getRelatedShadowDataSourceMappings(each);
             }
         }
         return Optional.empty();
     }
     
-    private boolean isShadowTable(final String tableName, final ShadowRule shadowRule, final ShadowOperationType shadowOperationType) {
-        ShadowDetermineCondition shadowDetermineCondition = new ShadowDetermineCondition(tableName, shadowOperationType);
-        Optional<Collection<NoteShadowAlgorithm<Comparable<?>>>> noteShadowAlgorithms = shadowRule.getRelatedNoteShadowAlgorithms(tableName);
-        Optional<Collection<String>> sqlNotes = parseSqlNotes();
-        if (noteShadowAlgorithms.isPresent() && sqlNotes.isPresent() && isMatchAnyNoteShadowAlgorithms(noteShadowAlgorithms.get(), shadowDetermineCondition.initSqlNotes(sqlNotes.get()), shadowRule)) {
+    private boolean isShadowTable(final String tableName, final ShadowRule shadowRule, final ShadowOperationType shadowOperationType, final boolean sqlCommentParseEnabled) {
+        ShadowDetermineCondition shadowCondition = new ShadowDetermineCondition(tableName, shadowOperationType);
+        if (sqlCommentParseEnabled && isShadowSqlNote(tableName, shadowRule, shadowCondition)) {
             return true;
         }
-        Optional<Collection<ColumnShadowAlgorithm<Comparable<?>>>> columnShadowAlgorithms = shadowRule.getRelatedColumnShadowAlgorithms(tableName, shadowOperationType);
-        Optional<Collection<ShadowColumnCondition>> shadowColumnConditions = parseShadowColumnConditions();
-        return columnShadowAlgorithms.isPresent() && shadowColumnConditions.isPresent() && isMatchAnyColumnShadowAlgorithms(columnShadowAlgorithms.get(),
-                shadowDetermineCondition.initShadowColumnCondition(shadowColumnConditions.get()), shadowRule);
+        return isShadowColumn(tableName, shadowRule, shadowCondition);
+    }
+    
+    private boolean isShadowSqlNote(final String tableName, final ShadowRule shadowRule, final ShadowDetermineCondition shadowCondition) {
+        return parseSqlNotes().filter(strings -> shadowRule.getRelatedNoteShadowAlgorithms(tableName)
+                .filter(shadowAlgorithms -> isMatchAnyNoteShadowAlgorithms(shadowAlgorithms, shadowCondition.initSqlNotes(strings), shadowRule)).isPresent()).isPresent();
     }
     
     private boolean isMatchAnyNoteShadowAlgorithms(final Collection<NoteShadowAlgorithm<Comparable<?>>> shadowAlgorithms, final ShadowDetermineCondition shadowCondition, final ShadowRule shadowRule) {
@@ -88,6 +91,11 @@ public abstract class AbstractShadowDMLStatementRouteEngine implements ShadowRou
         return ShadowDeterminerFactory.newInstance(noteShadowAlgorithm).isShadow(shadowCondition, shadowRule);
     }
     
+    private boolean isShadowColumn(final String tableName, final ShadowRule shadowRule, final ShadowDetermineCondition shadowCondition) {
+        return shadowRule.getRelatedColumnShadowAlgorithms(tableName, shadowCondition.getShadowOperationType()).filter(shadowAlgorithms -> parseShadowColumnConditions()
+                .filter(columnConditions -> isMatchAnyColumnShadowAlgorithms(shadowAlgorithms, shadowCondition.initShadowColumnCondition(columnConditions), shadowRule)).isPresent()).isPresent();
+    }
+    
     private boolean isMatchAnyColumnShadowAlgorithms(final Collection<ColumnShadowAlgorithm<Comparable<?>>> shadowAlgorithms, final ShadowDetermineCondition shadowCondition,
                                                      final ShadowRule shadowRule) {
         for (ColumnShadowAlgorithm<Comparable<?>> each : shadowAlgorithms) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngine.java
index fd4ff89..0c686aa 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngine.java
@@ -22,11 +22,9 @@ import org.apache.shardingsphere.infra.binder.statement.dml.DeleteStatementConte
 import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
 import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
 import org.apache.shardingsphere.shadow.route.engine.util.ShadowExtractor;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.util.ColumnExtractor;
 import org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil;
 
 import java.util.Collection;
@@ -60,12 +58,8 @@ public final class ShadowDeleteStatementRoutingEngine extends AbstractShadowDMLS
     }
     
     private void parseExpressionSegment(final ExpressionSegment expressionSegment, final Collection<ShadowColumnCondition> shadowColumnConditions) {
-        Collection<ColumnSegment> columnSegments = ColumnExtractor.extract(expressionSegment);
-        if (1 == columnSegments.size()) {
-            ColumnSegment columnSegment = columnSegments.iterator().next();
-            ShadowExtractor.extractValues(expressionSegment, parameters).ifPresent(values -> shadowColumnConditions.add(new ShadowColumnCondition(getSingleTableName(),
-                    columnSegment.getIdentifier().getValue(), values)));
-        }
+        ShadowExtractor.extractColumn(expressionSegment).ifPresent(columnSegment -> ShadowExtractor.extractValues(expressionSegment, parameters)
+                .ifPresent(values -> shadowColumnConditions.add(new ShadowColumnCondition(getSingleTableName(), columnSegment.getIdentifier().getValue(), values))));
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngine.java
index 7308df4..c1e24e0 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngine.java
@@ -41,8 +41,7 @@ public final class ShadowInsertStatementRoutingEngine extends AbstractShadowDMLS
     @Override
     protected Optional<Collection<ShadowColumnCondition>> parseShadowColumnConditions() {
         Collection<ShadowColumnCondition> result = new LinkedList<>();
-        Collection<String> columnNames = parseColumnNames();
-        Iterator<String> columnNamesIt = columnNames.iterator();
+        Iterator<String> columnNamesIt = parseColumnNames().iterator();
         List<InsertValueContext> insertValueContexts = insertStatementContext.getInsertValueContexts();
         int index = 0;
         while (columnNamesIt.hasNext()) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngine.java
index e2bc56c..0618081 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngine.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.Expressi
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.util.ColumnExtractor;
 import org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil;
 
 import java.util.Collection;
@@ -61,13 +60,8 @@ public final class ShadowSelectStatementRoutingEngine extends AbstractShadowDMLS
     }
     
     private void parseExpressionSegment(final ExpressionSegment expressionSegment, final Collection<ShadowColumnCondition> shadowColumnConditions) {
-        Collection<ColumnSegment> columnSegments = ColumnExtractor.extract(expressionSegment);
-        if (1 == columnSegments.size()) {
-            ColumnSegment columnSegment = columnSegments.iterator().next();
-            String columnName = columnSegment.getIdentifier().getValue();
-            String tableName = extractTableName(columnSegment);
-            ShadowExtractor.extractValues(expressionSegment, parameters).ifPresent(values -> shadowColumnConditions.add(new ShadowColumnCondition(tableName, columnName, values)));
-        }
+        ShadowExtractor.extractColumn(expressionSegment).ifPresent(columnSegment -> ShadowExtractor.extractValues(expressionSegment, parameters)
+                .ifPresent(values -> shadowColumnConditions.add(new ShadowColumnCondition(extractTableName(columnSegment), columnSegment.getIdentifier().getValue(), values))));
     }
     
     private String extractTableName(final ColumnSegment columnSegment) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngine.java
index dc7c9ec..c515e65 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngine.java
@@ -22,11 +22,9 @@ import org.apache.shardingsphere.infra.binder.statement.dml.UpdateStatementConte
 import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
 import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
 import org.apache.shardingsphere.shadow.route.engine.util.ShadowExtractor;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.util.ColumnExtractor;
 import org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil;
 
 import java.util.Collection;
@@ -60,12 +58,8 @@ public final class ShadowUpdateStatementRoutingEngine extends AbstractShadowDMLS
     }
     
     private void parseExpressionSegment(final ExpressionSegment expressionSegment, final Collection<ShadowColumnCondition> shadowColumnConditions) {
-        Collection<ColumnSegment> columnSegments = ColumnExtractor.extract(expressionSegment);
-        if (1 == columnSegments.size()) {
-            ColumnSegment columnSegment = columnSegments.iterator().next();
-            ShadowExtractor.extractValues(expressionSegment, parameters).ifPresent(values -> shadowColumnConditions.add(new ShadowColumnCondition(getSingleTableName(),
-                    columnSegment.getIdentifier().getValue(), values)));
-        }
+        ShadowExtractor.extractColumn(expressionSegment).ifPresent(columnSegment -> ShadowExtractor.extractValues(expressionSegment, parameters)
+                .ifPresent(values -> shadowColumnConditions.add(new ShadowColumnCondition(getSingleTableName(), columnSegment.getIdentifier().getValue(), values))));
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngine.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngine.java
index b3c93be..1b76fa5 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngine.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngine.java
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.shadow.route.engine.impl;
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -28,12 +30,14 @@ import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition;
 import org.apache.shardingsphere.shadow.route.engine.ShadowRouteEngine;
 import org.apache.shardingsphere.shadow.route.engine.determiner.ShadowDeterminerFactory;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.CommentSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
 
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * Shadow non-DML statement routing engine.
@@ -44,32 +48,38 @@ public final class ShadowNonDMLStatementRoutingEngine implements ShadowRouteEngi
     private final SQLStatementContext<?> sqlStatementContext;
     
     @Override
-    public void route(final RouteContext routeContext, final ShadowRule shadowRule) {
-        findShadowDataSourceMappings(shadowRule).ifPresent(stringStringMap -> shadowNonDMLStatementRouteDecorate(routeContext, stringStringMap));
+    public void route(final RouteContext routeContext, final ShadowRule shadowRule, final ConfigurationProperties props) {
+        if (Boolean.parseBoolean(String.valueOf(props.getProps().get(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey())))) {
+            findShadowDataSourceMappings(shadowRule).ifPresent(stringStringMap -> shadowNonDMLStatementRouteDecorate(routeContext, stringStringMap));
+        }
     }
     
     private Optional<Map<String, String>> findShadowDataSourceMappings(final ShadowRule shadowRule) {
-        Optional<Collection<NoteShadowAlgorithm<Comparable<?>>>> noteShadowAlgorithms = shadowRule.getAllNoteShadowAlgorithms();
-        if (!noteShadowAlgorithms.isPresent()) {
-            return Optional.empty();
-        }
         Optional<Collection<String>> sqlNotes = parseSqlNotes();
         if (!sqlNotes.isPresent()) {
             return Optional.empty();
         }
-        ShadowDetermineCondition shadowDetermineCondition = new ShadowDetermineCondition("", ShadowOperationType.NON_DML);
-        if (isMatchAnyNoteShadowAlgorithms(noteShadowAlgorithms.get(), shadowDetermineCondition.initSqlNotes(sqlNotes.get()), shadowRule)) {
+        Optional<Collection<NoteShadowAlgorithm<Comparable<?>>>> noteShadowAlgorithms = shadowRule.getAllNoteShadowAlgorithms();
+        if (!noteShadowAlgorithms.isPresent()) {
+            return Optional.empty();
+        }
+        if (isMatchAnyNoteShadowAlgorithms(noteShadowAlgorithms.get(), createShadowDetermineCondition(sqlNotes.get()), shadowRule)) {
             return Optional.of(shadowRule.getAllShadowDataSourceMappings());
         }
         return Optional.empty();
     }
     
     private Optional<Collection<String>> parseSqlNotes() {
-        Collection<String> result = new LinkedList<>();
-        ((AbstractSQLStatement) sqlStatementContext.getSqlStatement()).getCommentSegments().forEach(each -> result.add(each.getText()));
+        Collection<String> result = ((AbstractSQLStatement) sqlStatementContext.getSqlStatement()).getCommentSegments().stream().map(CommentSegment::getText)
+                .collect(Collectors.toCollection(LinkedList::new));
         return result.isEmpty() ? Optional.empty() : Optional.of(result);
     }
     
+    private ShadowDetermineCondition createShadowDetermineCondition(final Collection<String> sqlNotes) {
+        ShadowDetermineCondition result = new ShadowDetermineCondition("", ShadowOperationType.NON_DML);
+        return result.initSqlNotes(sqlNotes);
+    }
+    
     private boolean isMatchAnyNoteShadowAlgorithms(final Collection<NoteShadowAlgorithm<Comparable<?>>> shadowAlgorithms, final ShadowDetermineCondition shadowCondition, final ShadowRule shadowRule) {
         for (NoteShadowAlgorithm<Comparable<?>> each : shadowAlgorithms) {
             if (isMatchNoteShadowAlgorithm(each, shadowCondition, shadowRule)) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/util/ShadowExtractor.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/util/ShadowExtractor.java
index 7a5c09e..b718792 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/util/ShadowExtractor.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/engine/util/ShadowExtractor.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.shadow.route.engine.util;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.InExpression;
@@ -26,6 +27,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ListExpr
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.SimpleExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.util.ColumnExtractor;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -39,6 +41,17 @@ import java.util.Optional;
 public final class ShadowExtractor {
     
     /**
+     * Get column in expression segment.
+     *
+     * @param expressionSegment expression segment
+     * @return column segment
+     */
+    public static Optional<ColumnSegment> extractColumn(final ExpressionSegment expressionSegment) {
+        Collection<ColumnSegment> columnSegments = ColumnExtractor.extract(expressionSegment);
+        return 1 == columnSegments.size() ? Optional.of(columnSegments.iterator().next()) : Optional.empty();
+    }
+    
+    /**
      * Get values in expression segment.
      *
      * @param expression expression segment
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
index 9477c06..ebba2f3 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
@@ -83,10 +83,7 @@ public final class ShadowRule implements SchemaRule, DataSourceContainedRule {
     }
     
     private void initShadowTableRules(final Map<String, ShadowTableConfiguration> tables) {
-        tables.forEach((key, value) -> {
-            Collection<String> tableShadowAlgorithmNames = value.getShadowAlgorithmNames();
-            shadowTableRules.put(key, new ShadowTableRule(key, value.getDataSourceNames(), tableShadowAlgorithmNames, shadowAlgorithms));
-        });
+        tables.forEach((key, value) -> shadowTableRules.put(key, new ShadowTableRule(key, value.getDataSourceNames(), value.getShadowAlgorithmNames(), shadowAlgorithms)));
     }
     
     private void initShadowAlgorithms(final Map<String, ShadowAlgorithm> shadowAlgorithms) {
@@ -123,12 +120,8 @@ public final class ShadowRule implements SchemaRule, DataSourceContainedRule {
      */
     @SuppressWarnings("unchecked")
     public Optional<Collection<NoteShadowAlgorithm<Comparable<?>>>> getAllNoteShadowAlgorithms() {
-        Collection<NoteShadowAlgorithm<Comparable<?>>> result = new LinkedList<>();
-        shadowAlgorithms.values().forEach(each -> {
-            if (each instanceof NoteShadowAlgorithm<?>) {
-                result.add((NoteShadowAlgorithm<Comparable<?>>) each);
-            }
-        });
+        Collection<NoteShadowAlgorithm<Comparable<?>>> result = shadowAlgorithms.values().stream().filter(each -> each instanceof NoteShadowAlgorithm<?>)
+                .map(each -> (NoteShadowAlgorithm<Comparable<?>>) each).collect(Collectors.toCollection(LinkedList::new));
         return result.isEmpty() ? Optional.empty() : Optional.of(result);
     }
     
@@ -140,15 +133,9 @@ public final class ShadowRule implements SchemaRule, DataSourceContainedRule {
      */
     @SuppressWarnings("unchecked")
     public Optional<Collection<NoteShadowAlgorithm<Comparable<?>>>> getRelatedNoteShadowAlgorithms(final String tableName) {
-        Collection<NoteShadowAlgorithm<Comparable<?>>> result = new LinkedList<>();
-        ShadowTableRule shadowTableRule = shadowTableRules.get(tableName);
-        Collection<String> noteShadowAlgorithmNames = shadowTableRule.getNoteShadowAlgorithmNames();
-        noteShadowAlgorithmNames.forEach(each -> {
-            ShadowAlgorithm shadowAlgorithm = shadowAlgorithms.get(each);
-            if (!Objects.isNull(shadowAlgorithm)) {
-                result.add((NoteShadowAlgorithm<Comparable<?>>) shadowAlgorithm);
-            }
-        });
+        Collection<NoteShadowAlgorithm<Comparable<?>>> result = shadowTableRules.get(tableName).getNoteShadowAlgorithmNames().stream().map(shadowAlgorithms::get)
+                .filter(shadowAlgorithm -> !Objects.isNull(shadowAlgorithm)).map(shadowAlgorithm -> (NoteShadowAlgorithm<Comparable<?>>) shadowAlgorithm)
+                .collect(Collectors.toCollection(LinkedList::new));
         return result.isEmpty() ? Optional.of(result) : Optional.of(result);
     }
     
@@ -161,15 +148,9 @@ public final class ShadowRule implements SchemaRule, DataSourceContainedRule {
      */
     @SuppressWarnings("unchecked")
     public Optional<Collection<ColumnShadowAlgorithm<Comparable<?>>>> getRelatedColumnShadowAlgorithms(final String tableName, final ShadowOperationType shadowOperationType) {
-        Collection<ColumnShadowAlgorithm<Comparable<?>>> result = new LinkedList<>();
-        ShadowTableRule shadowTableRule = shadowTableRules.get(tableName);
-        Collection<String> columnShadowAlgorithmNames = shadowTableRule.getColumnShadowAlgorithmNames().get(shadowOperationType);
-        columnShadowAlgorithmNames.forEach(each -> {
-            ShadowAlgorithm shadowAlgorithm = shadowAlgorithms.get(each);
-            if (!Objects.isNull(shadowAlgorithm)) {
-                result.add((ColumnShadowAlgorithm<Comparable<?>>) shadowAlgorithm);
-            }
-        });
+        Collection<ColumnShadowAlgorithm<Comparable<?>>> result = shadowTableRules.get(tableName).getColumnShadowAlgorithmNames().get(shadowOperationType).stream().map(shadowAlgorithms::get)
+                .filter(shadowAlgorithm -> !Objects.isNull(shadowAlgorithm)).map(shadowAlgorithm -> (ColumnShadowAlgorithm<Comparable<?>>) shadowAlgorithm)
+                .collect(Collectors.toCollection(LinkedList::new));
         return result.isEmpty() ? Optional.of(result) : Optional.of(result);
     }
     
@@ -180,14 +161,8 @@ public final class ShadowRule implements SchemaRule, DataSourceContainedRule {
      * @return shadow data source rules
      */
     public Optional<Map<String, String>> getRelatedShadowDataSourceMappings(final String tableName) {
-        Map<String, String> result = new LinkedHashMap<>();
-        Collection<String> shadowDataSources = shadowTableRules.get(tableName).getShadowDataSources();
-        shadowDataSources.forEach(each -> {
-            ShadowDataSourceRule shadowDataSourceRule = shadowDataSourceMappings.get(each);
-            if (null != shadowDataSourceRule) {
-                result.put(shadowDataSourceRule.getSourceDataSource(), shadowDataSourceRule.getShadowDataSource());
-            }
-        });
+        Map<String, String> result = shadowTableRules.get(tableName).getShadowDataSources().stream().map(shadowDataSourceMappings::get).filter(Objects::nonNull)
+                .collect(Collectors.toMap(ShadowDataSourceRule::getSourceDataSource, ShadowDataSourceRule::getShadowDataSource, (a, b) -> b, LinkedHashMap::new));
         return result.isEmpty() ? Optional.empty() : Optional.of(result);
     }
     
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/ColumnShadowAlgorithmDeterminerTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/ColumnShadowAlgorithmDeterminerTest.java
index 11c0c6f..0152a09 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/ColumnShadowAlgorithmDeterminerTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/ColumnShadowAlgorithmDeterminerTest.java
@@ -105,9 +105,9 @@ public final class ColumnShadowAlgorithmDeterminerTest {
     }
     
     private ShadowDetermineCondition createShadowDetermineCondition() {
-        ShadowDetermineCondition shadowDetermineCondition = new ShadowDetermineCondition("t_order", ShadowOperationType.INSERT);
-        shadowDetermineCondition.initShadowColumnCondition(createColumnValuesMappings());
-        return shadowDetermineCondition;
+        ShadowDetermineCondition result = new ShadowDetermineCondition("t_order", ShadowOperationType.INSERT);
+        result.initShadowColumnCondition(createColumnValuesMappings());
+        return result;
     }
     
     private Collection<ShadowColumnCondition> createColumnValuesMappings() {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/NoteShadowAlgorithmDeterminerTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/NoteShadowAlgorithmDeterminerTest.java
index b2f31b3..61879bc 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/NoteShadowAlgorithmDeterminerTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/algorithm/NoteShadowAlgorithmDeterminerTest.java
@@ -104,14 +104,8 @@ public final class NoteShadowAlgorithmDeterminerTest {
     }
     
     private ShadowDetermineCondition createShadowDetermineCondition() {
-        ShadowDetermineCondition shadowDetermineCondition = new ShadowDetermineCondition("t_order", ShadowOperationType.INSERT);
-        shadowDetermineCondition.initSqlNotes(createSqlNotes());
-        return shadowDetermineCondition;
-    }
-
-    private Collection<String> createSqlNotes() {
-        Collection<String> result = new LinkedList<>();
-        result.add("/*foo:bar,shadow:true*/");
+        ShadowDetermineCondition result = new ShadowDetermineCondition("t_order", ShadowOperationType.INSERT);
+        result.initSqlNotes(Collections.singletonList("/*foo:bar,shadow:true*/"));
         return result;
     }
 }
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngineTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngineTest.java
index a1d0195..f73fe3c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngineTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowDeleteStatementRoutingEngineTest.java
@@ -18,6 +18,8 @@
 package org.apache.shardingsphere.shadow.route.engine.dml;
 
 import org.apache.shardingsphere.infra.binder.statement.dml.DeleteStatementContext;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -88,7 +90,9 @@ public final class ShadowDeleteStatementRoutingEngineTest {
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds", "ds_shadow"), new LinkedList<>()));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        shadowDeleteStatementRoutingEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()));
+        Properties props = new Properties();
+        props.setProperty(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey(), String.valueOf(Boolean.TRUE));
+        shadowDeleteStatementRoutingEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()), new ConfigurationProperties(props));
         Optional<Collection<ShadowColumnCondition>> shadowColumnConditions = shadowDeleteStatementRoutingEngine.parseShadowColumnConditions();
         assertThat(shadowColumnConditions.isPresent(), is(true));
         Collection<ShadowColumnCondition> shadowColumns = shadowColumnConditions.get();
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngineTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngineTest.java
index 83d626d..97db196 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngineTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowInsertStatementRoutingEngineTest.java
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.shadow.route.engine.dml;
 
 import org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext;
 import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -93,7 +95,9 @@ public final class ShadowInsertStatementRoutingEngineTest {
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds", "ds_shadow"), new LinkedList<>()));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        shadowRouteEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()));
+        Properties props = new Properties();
+        props.setProperty(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey(), String.valueOf(Boolean.TRUE));
+        shadowRouteEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()), new ConfigurationProperties(props));
         Optional<Collection<ShadowColumnCondition>> shadowColumnConditions = shadowRouteEngine.parseShadowColumnConditions();
         assertThat(shadowColumnConditions.isPresent(), is(true));
         Collection<ShadowColumnCondition> shadowColumns = shadowColumnConditions.get();
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngineTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngineTest.java
index 6cb5659..d3d81fe 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngineTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowSelectStatementRoutingEngineTest.java
@@ -18,6 +18,8 @@
 package org.apache.shardingsphere.shadow.route.engine.dml;
 
 import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -88,7 +90,9 @@ public final class ShadowSelectStatementRoutingEngineTest {
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds", "ds_shadow"), new LinkedList<>()));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        shadowRouteEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()));
+        Properties props = new Properties();
+        props.setProperty(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey(), String.valueOf(Boolean.TRUE));
+        shadowRouteEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()), new ConfigurationProperties(props));
         Optional<Collection<ShadowColumnCondition>> shadowColumnConditions = shadowRouteEngine.parseShadowColumnConditions();
         assertThat(shadowColumnConditions.isPresent(), is(true));
         Collection<ShadowColumnCondition> shadowColumns = shadowColumnConditions.get();
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngineTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngineTest.java
index ef0a234..06d969e 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngineTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/engine/dml/ShadowUpdateStatementRoutingEngineTest.java
@@ -18,6 +18,8 @@
 package org.apache.shardingsphere.shadow.route.engine.dml;
 
 import org.apache.shardingsphere.infra.binder.statement.dml.UpdateStatementContext;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -89,7 +91,9 @@ public final class ShadowUpdateStatementRoutingEngineTest {
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds", "ds_shadow"), new LinkedList<>()));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        shadowRouteEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()));
+        Properties props = new Properties();
+        props.setProperty(ConfigurationPropertyKey.SQL_COMMENT_PARSE_ENABLED.getKey(), String.valueOf(Boolean.TRUE));
+        shadowRouteEngine.route(routeContext, new ShadowRule(createAlgorithmProvidedShadowRuleConfiguration()), new ConfigurationProperties(props));
         Optional<Collection<ShadowColumnCondition>> shadowColumnConditions = shadowRouteEngine.parseShadowColumnConditions();
         assertTrue(shadowColumnConditions.isPresent());
         Collection<ShadowColumnCondition> shadowColumns = shadowColumnConditions.get();