diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/combine/CombineSegmentBinder.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/combine/CombineSegmentBinder.java index cc76a637d8a31..d2e83429fe8e4 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/combine/CombineSegmentBinder.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/combine/CombineSegmentBinder.java @@ -46,8 +46,8 @@ public static CombineSegment bind(final CombineSegment segment, final SQLStateme ShardingSphereMetaData metaData = statementBinderContext.getMetaData(); String currentDatabaseName = statementBinderContext.getCurrentDatabaseName(); Map externalTableBinderContexts = statementBinderContext.getExternalTableBinderContexts(); - SelectStatement boundedLeftSelect = new SelectStatementBinder().bindWithExternalTableContexts(segment.getLeft().getSelect(), metaData, currentDatabaseName, externalTableBinderContexts); - SelectStatement boundedRightSelect = new SelectStatementBinder().bindWithExternalTableContexts(segment.getRight().getSelect(), metaData, currentDatabaseName, externalTableBinderContexts); + SelectStatement boundedLeftSelect = new SelectStatementBinder().bind(segment.getLeft().getSelect(), metaData, currentDatabaseName, externalTableBinderContexts); + SelectStatement boundedRightSelect = new SelectStatementBinder().bind(segment.getRight().getSelect(), metaData, currentDatabaseName, externalTableBinderContexts); SubquerySegment boundedLeft = new SubquerySegment(segment.getLeft().getStartIndex(), segment.getLeft().getStopIndex(), segment.getLeft().getText()); boundedLeft.setSelect(boundedLeftSelect); boundedLeft.setSubqueryType(segment.getLeft().getSubqueryType()); diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/SQLStatementBinder.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/SQLStatementBinder.java index a6fc368f2c577..54280df826ed5 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/SQLStatementBinder.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/SQLStatementBinder.java @@ -28,12 +28,12 @@ public interface SQLStatementBinder { /** - * Bind SQL statement with metadata. + * Bind SQL statement. * * @param sqlStatement SQL statement * @param metaData meta data * @param currentDatabaseName current database name - * @return bounded SQL statement + * @return bound SQL statement */ T bind(T sqlStatement, ShardingSphereMetaData metaData, String currentDatabaseName); } 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 66b8867e762b9..a663d2f6945b4 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 @@ -41,6 +41,35 @@ */ public final class SelectStatementBinder implements SQLStatementBinder { + /** + * Bind correlate subquery select statement. + * + * @param sqlStatement subquery select statement + * @param metaData meta data + * @param currentDatabaseName current database name + * @param outerTableBinderContexts outer select statement table binder contexts + * @param externalTableBinderContexts external table binder contexts + * @return bounded correlate subquery select statement + */ + public SelectStatement bindCorrelateSubquery(final SelectStatement sqlStatement, final ShardingSphereMetaData metaData, final String currentDatabaseName, + final Map outerTableBinderContexts, final Map externalTableBinderContexts) { + return bind(sqlStatement, metaData, currentDatabaseName, outerTableBinderContexts, externalTableBinderContexts); + } + + /** + * Bind with external table contexts. + * + * @param statement select statement + * @param metaData meta data + * @param currentDatabaseName current database name + * @param externalTableContexts external table contexts + * @return select statement + */ + public SelectStatement bind(final SelectStatement statement, final ShardingSphereMetaData metaData, final String currentDatabaseName, + final Map externalTableContexts) { + return bind(statement, metaData, currentDatabaseName, Collections.emptyMap(), externalTableContexts); + } + @Override public SelectStatement bind(final SelectStatement sqlStatement, final ShardingSphereMetaData metaData, final String currentDatabaseName) { return bind(sqlStatement, metaData, currentDatabaseName, Collections.emptyMap(), Collections.emptyMap()); @@ -77,33 +106,4 @@ private SelectStatement copy(final SelectStatement sqlStatement) { result.getCommentSegments().addAll(sqlStatement.getCommentSegments()); return result; } - - /** - * Bind correlate subquery select statement. - * - * @param sqlStatement subquery select statement - * @param metaData meta data - * @param currentDatabaseName current database name - * @param outerTableBinderContexts outer select statement table binder contexts - * @param externalTableBinderContexts external table binder contexts - * @return bounded correlate subquery select statement - */ - public SelectStatement bindCorrelateSubquery(final SelectStatement sqlStatement, final ShardingSphereMetaData metaData, final String currentDatabaseName, - final Map outerTableBinderContexts, final Map externalTableBinderContexts) { - return bind(sqlStatement, metaData, currentDatabaseName, outerTableBinderContexts, externalTableBinderContexts); - } - - /** - * Bind with external table contexts. - * - * @param statement select statement - * @param metaData meta data - * @param currentDatabaseName current database name - * @param externalTableContexts external table contexts - * @return select statement - */ - public SelectStatement bindWithExternalTableContexts(final SelectStatement statement, final ShardingSphereMetaData metaData, final String currentDatabaseName, - final Map externalTableContexts) { - return bind(statement, metaData, currentDatabaseName, Collections.emptyMap(), externalTableContexts); - } }