You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/11 05:53:43 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #21346: Support sharding SQL hint.

strongduanmu commented on code in PR #21346:
URL: https://github.com/apache/shardingsphere/pull/21346#discussion_r991840038


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java:
##########
@@ -94,6 +98,17 @@ private boolean isRoutingByHint(final ShardingRule shardingRule, final TableRule
                 && shardingRule.getTableShardingStrategyConfiguration(tableRule) instanceof HintShardingStrategyConfiguration;
     }
     
+    private boolean isRoutingBySQLHint() {
+        boolean result = false;
+        if (sqlStatementContext instanceof CommonSQLStatementContext) {
+            Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
+            for (String each : tableNames) {
+                result = result || ((CommonSQLStatementContext<?>) sqlStatementContext).containsHintShardingValue(each);

Review Comment:
   Can you use guard clause here? Just like:
   
   ```java
   if (CommonSQLStatementContext<?>) sqlStatementContext).containsHintShardingValue(each) {
   return true;
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org