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

chengzhang 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 aa5e2c0fb12 Fix sonar issue in ProjectionsSegmentBinder class (#27550)
aa5e2c0fb12 is described below

commit aa5e2c0fb12d6aec20c14c42f52528318e58bef5
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Sat Jul 29 07:19:46 2023 +0800

    Fix sonar issue in ProjectionsSegmentBinder class (#27550)
---
 .../binder/segment/projection/ProjectionsSegmentBinder.java | 13 ++++---------
 .../infra/binder/statement/dml/SelectStatementBinder.java   |  9 +++------
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/projection/ProjectionsSegmentBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/projection/ProjectionsSegmentBinder.java
index 4aa354feafb..2efa2510ff8 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/projection/ProjectionsSegmentBinder.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/projection/ProjectionsSegmentBinder.java
@@ -17,20 +17,18 @@
 
 package org.apache.shardingsphere.infra.binder.segment.projection;
 
+import java.util.Map;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.infra.binder.segment.from.TableSegmentBinderContext;
 import 
org.apache.shardingsphere.infra.binder.segment.projection.impl.ColumnProjectionSegmentBinder;
 import 
org.apache.shardingsphere.infra.binder.segment.projection.impl.ShorthandProjectionSegmentBinder;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ColumnProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ShorthandProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
 
-import java.util.Map;
-
 /**
  * Projections segment binder.
  */
@@ -42,20 +40,17 @@ public final class ProjectionsSegmentBinder {
      *
      * @param segment table segment
      * @param boundedTableSegment bounded table segment
-     * @param databaseType database type
      * @param tableBinderContexts table binder contexts
      * @return bounded projections segment
      */
-    public static ProjectionsSegment bind(final ProjectionsSegment segment, 
final TableSegment boundedTableSegment,
-                                          final DatabaseType databaseType, 
final Map<String, TableSegmentBinderContext> tableBinderContexts) {
+    public static ProjectionsSegment bind(final ProjectionsSegment segment, 
final TableSegment boundedTableSegment, final Map<String, 
TableSegmentBinderContext> tableBinderContexts) {
         ProjectionsSegment result = new 
ProjectionsSegment(segment.getStartIndex(), segment.getStopIndex());
         result.setDistinctRow(segment.isDistinctRow());
-        segment.getProjections().forEach(each -> 
result.getProjections().add(bind(each, boundedTableSegment, databaseType, 
tableBinderContexts)));
+        segment.getProjections().forEach(each -> 
result.getProjections().add(bind(each, boundedTableSegment, 
tableBinderContexts)));
         return result;
     }
     
-    private static ProjectionSegment bind(final ProjectionSegment 
projectionSegment, final TableSegment boundedTableSegment,
-                                          final DatabaseType databaseType, 
final Map<String, TableSegmentBinderContext> tableBinderContexts) {
+    private static ProjectionSegment bind(final ProjectionSegment 
projectionSegment, final TableSegment boundedTableSegment, final Map<String, 
TableSegmentBinderContext> tableBinderContexts) {
         if (projectionSegment instanceof ColumnProjectionSegment) {
             return 
ColumnProjectionSegmentBinder.bind((ColumnProjectionSegment) projectionSegment, 
tableBinderContexts);
         }
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementBinder.java
index 785db2b6638..9faefac1fd4 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementBinder.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementBinder.java
@@ -17,19 +17,17 @@
 
 package org.apache.shardingsphere.infra.binder.statement.dml;
 
+import java.util.Map;
 import org.apache.commons.collections4.map.CaseInsensitiveMap;
 import 
org.apache.shardingsphere.infra.binder.segment.combine.CombineSegmentBinder;
 import org.apache.shardingsphere.infra.binder.segment.from.TableSegmentBinder;
 import 
org.apache.shardingsphere.infra.binder.segment.from.TableSegmentBinderContext;
 import 
org.apache.shardingsphere.infra.binder.segment.projection.ProjectionsSegmentBinder;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementBinder;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
 
-import java.util.Map;
-
 /**
  * Select statement binder.
  */
@@ -38,11 +36,10 @@ public final class SelectStatementBinder implements 
SQLStatementBinder<SelectSta
     @Override
     public SelectStatement bind(final SelectStatement sqlStatement, final 
ShardingSphereMetaData metaData, final String defaultDatabaseName) {
         Map<String, TableSegmentBinderContext> tableBinderContexts = new 
CaseInsensitiveMap<>();
-        DatabaseType databaseType = sqlStatement.getDatabaseType();
-        TableSegment boundedTableSegment = 
TableSegmentBinder.bind(sqlStatement.getFrom(), metaData, defaultDatabaseName, 
databaseType, tableBinderContexts);
+        TableSegment boundedTableSegment = 
TableSegmentBinder.bind(sqlStatement.getFrom(), metaData, defaultDatabaseName, 
sqlStatement.getDatabaseType(), tableBinderContexts);
         sqlStatement.setFrom(boundedTableSegment);
         sqlStatement.getCombine().ifPresent(optional -> 
sqlStatement.setCombine(CombineSegmentBinder.bind(optional, metaData, 
defaultDatabaseName)));
-        
sqlStatement.setProjections(ProjectionsSegmentBinder.bind(sqlStatement.getProjections(),
 boundedTableSegment, databaseType, tableBinderContexts));
+        
sqlStatement.setProjections(ProjectionsSegmentBinder.bind(sqlStatement.getProjections(),
 boundedTableSegment, tableBinderContexts));
         // TODO support other segment bind in select statement
         return sqlStatement;
     }

Reply via email to