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

jianglongtao 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 8b1c2b92f03 Remove useless `resultSet` `resultSetHandler` 
`queryableRALHandler` (#24045)
8b1c2b92f03 is described below

commit 8b1c2b92f035ed69dd6c33c2b70de21e7e70a527
Author: Zichao <[email protected]>
AuthorDate: Wed Feb 8 15:56:08 2023 +1300

    Remove useless `resultSet` `resultSetHandler` `queryableRALHandler` (#24045)
---
 .../resultset/GlobalRuleDistSQLResultSet.java      | 35 --------
 .../ral/AbstractQueryableRALBackendHandler.java    | 83 ------------------
 .../ral/QueryableGlobalRuleRALBackendHandler.java  | 68 ---------------
 .../distsql/ral/RALBackendHandlerFactory.java      | 15 ----
 .../query/QueryableScalingRALBackendHandler.java   | 69 ---------------
 .../distsql/rql/RQLBackendHandlerFactory.java      | 12 ---
 .../distsql/rql/RQLResultSetBackendHandler.java    | 72 ----------------
 .../rql/RQLResultSetBackendHandlerTest.java        | 99 ----------------------
 8 files changed, 453 deletions(-)

diff --git 
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/resultset/GlobalRuleDistSQLResultSet.java
 
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/resultset/GlobalRuleDistSQLResultSet.java
deleted file mode 100644
index fc0bb0a494b..00000000000
--- 
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/resultset/GlobalRuleDistSQLResultSet.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.distsql.handler.resultset;
-
-import 
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-/**
- * DistSQL result set for global rule.
- */
-public interface GlobalRuleDistSQLResultSet extends DistSQLResultSet {
-    
-    /**
-     * Initialize data.
-     *
-     * @param globalRuleMetaData global rule meta data
-     * @param sqlStatement SQL statement
-     */
-    void init(ShardingSphereRuleMetaData globalRuleMetaData, SQLStatement 
sqlStatement);
-}
diff --git 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/AbstractQueryableRALBackendHandler.java
 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/AbstractQueryableRALBackendHandler.java
deleted file mode 100644
index 02e3f01d4e2..00000000000
--- 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/AbstractQueryableRALBackendHandler.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.proxy.backend.handler.distsql.ral;
-
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
-import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataMergedResult;
-import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Queryable RAL backend handler.
- * TODO Remove this class when #23854 is done
- * 
- * @param <T> type of queryable RAL statement
- */
-public abstract class AbstractQueryableRALBackendHandler<T extends 
QueryableRALStatement> extends RALBackendHandler<T> {
-    
-    private List<QueryHeader> queryHeaders;
-    
-    private MergedResult mergedResult;
-    
-    @Override
-    public final ResponseHeader execute() {
-        queryHeaders = createQueryHeader();
-        mergedResult = createMergedResult();
-        return new QueryResponseHeader(queryHeaders);
-    }
-    
-    private List<QueryHeader> createQueryHeader() {
-        return getColumnNames().stream().map(each -> new QueryHeader("", "", 
each, each, Types.CHAR, "CHAR", 255, 0, false, false, false, 
false)).collect(Collectors.toList());
-    }
-    
-    private MergedResult createMergedResult() {
-        return new 
LocalDataMergedResult(getRows(ProxyContext.getInstance().getContextManager()));
-    }
-    
-    @Override
-    public final boolean next() throws SQLException {
-        return null != mergedResult && mergedResult.next();
-    }
-    
-    @Override
-    public final QueryResponseRow getRowData() throws SQLException {
-        List<QueryResponseCell> cells = new ArrayList<>(queryHeaders.size());
-        for (int i = 0; i < queryHeaders.size(); i++) {
-            cells.add(new 
QueryResponseCell(queryHeaders.get(i).getColumnType(), mergedResult.getValue(i 
+ 1, Object.class)));
-        }
-        return new QueryResponseRow(cells);
-    }
-    
-    protected abstract Collection<String> getColumnNames();
-    
-    protected abstract Collection<LocalDataQueryResultRow> 
getRows(ContextManager contextManager);
-}
diff --git 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableGlobalRuleRALBackendHandler.java
 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableGlobalRuleRALBackendHandler.java
deleted file mode 100644
index 9e9ba1d3dc4..00000000000
--- 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableGlobalRuleRALBackendHandler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.proxy.backend.handler.distsql.ral;
-
-import lombok.RequiredArgsConstructor;
-import 
org.apache.shardingsphere.distsql.handler.resultset.GlobalRuleDistSQLResultSet;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Queryable RAL backend handler for global rule.
- */
-@RequiredArgsConstructor
-public final class QueryableGlobalRuleRALBackendHandler implements 
DistSQLBackendHandler {
-    
-    private final RALStatement sqlStatement;
-    
-    private final GlobalRuleDistSQLResultSet resultSet;
-    
-    @Override
-    public ResponseHeader execute() {
-        
resultSet.init(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
 sqlStatement);
-        return new QueryResponseHeader(resultSet.getColumnNames().stream()
-                .map(each -> new QueryHeader("", "", each, each, Types.CHAR, 
"CHAR", 255, 0, false, false, false, false)).collect(Collectors.toList()));
-    }
-    
-    @Override
-    public boolean next() {
-        return resultSet.next();
-    }
-    
-    @Override
-    public QueryResponseRow getRowData() {
-        Collection<Object> rowData = resultSet.getRowData();
-        List<QueryResponseCell> result = new ArrayList<>(rowData.size());
-        for (Object each : rowData) {
-            result.add(new QueryResponseCell(Types.CHAR, each));
-        }
-        return new QueryResponseRow(result);
-    }
-}
diff --git 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
index 44b2eb3610b..c24367240aa 100644
--- 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
+++ 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
@@ -20,15 +20,10 @@ package 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor;
-import 
org.apache.shardingsphere.distsql.handler.resultset.DatabaseDistSQLResultSet;
-import org.apache.shardingsphere.distsql.handler.resultset.DistSQLResultSet;
-import 
org.apache.shardingsphere.distsql.handler.resultset.GlobalRuleDistSQLResultSet;
 import org.apache.shardingsphere.distsql.handler.update.GlobalRuleRALUpdater;
 import org.apache.shardingsphere.distsql.parser.statement.ral.HintRALStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableGlobalRuleRALStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableGlobalRuleRALStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.scaling.QueryableScalingRALStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.scaling.UpdatableScalingRALStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.updatable.ApplyDistSQLStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.updatable.DiscardDistSQLStatement;
@@ -45,7 +40,6 @@ import 
org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.
 import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.HintRALBackendHandler;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.migration.query.QueryableScalingRALBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.migration.update.UpdatableScalingRALBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.AlterReadwriteSplittingStorageUnitStatusStatementHandler;
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.ApplyDistSQLHandler;
@@ -94,24 +88,15 @@ public final class RALBackendHandlerFactory {
      * @return created instance
      */
     public static ProxyBackendHandler newInstance(final RALStatement 
sqlStatement, final ConnectionSession connectionSession) {
-        // TODO delete other if branches after replacing all query handlers 
with QueryableRALBackendHandler
         if (TypedSPILoader.contains(QueryableRALExecutor.class, 
sqlStatement.getClass().getName())) {
             return new QueryableRALBackendHandler<>(sqlStatement, 
connectionSession);
         }
         if (sqlStatement instanceof HintRALStatement) {
             return new HintRALBackendHandler((HintRALStatement) sqlStatement, 
connectionSession);
         }
-        if (sqlStatement instanceof QueryableScalingRALStatement) {
-            return new 
QueryableScalingRALBackendHandler((QueryableScalingRALStatement) sqlStatement,
-                    (DatabaseDistSQLResultSet) 
TypedSPILoader.getService(DistSQLResultSet.class, 
sqlStatement.getClass().getName()));
-        }
         if (sqlStatement instanceof UpdatableScalingRALStatement) {
             return new 
UpdatableScalingRALBackendHandler((UpdatableScalingRALStatement) sqlStatement, 
connectionSession);
         }
-        if (sqlStatement instanceof QueryableGlobalRuleRALStatement) {
-            return new QueryableGlobalRuleRALBackendHandler(sqlStatement,
-                    (GlobalRuleDistSQLResultSet) 
TypedSPILoader.getService(DistSQLResultSet.class, 
sqlStatement.getClass().getName()));
-        }
         if (sqlStatement instanceof UpdatableGlobalRuleRALStatement) {
             return new UpdatableGlobalRuleRALBackendHandler(sqlStatement, 
TypedSPILoader.getService(GlobalRuleRALUpdater.class, 
sqlStatement.getClass().getName()));
         }
diff --git 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/migration/query/QueryableScalingRALBackendHandler.java
 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/migration/query/QueryableScalingRALBackendHandler.java
deleted file mode 100644
index 8961e7180c9..00000000000
--- 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/migration/query/QueryableScalingRALBackendHandler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.proxy.backend.handler.distsql.ral.migration.query;
-
-import lombok.RequiredArgsConstructor;
-import 
org.apache.shardingsphere.distsql.handler.resultset.DatabaseDistSQLResultSet;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.scaling.QueryableScalingRALStatement;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Queryable scaling RAL backend handler.
- */
-@RequiredArgsConstructor
-public final class QueryableScalingRALBackendHandler implements 
DistSQLBackendHandler {
-    
-    private final QueryableScalingRALStatement sqlStatement;
-    
-    private final DatabaseDistSQLResultSet resultSet;
-    
-    @Override
-    public ResponseHeader execute() {
-        resultSet.init(null, sqlStatement);
-        List<QueryHeader> queryHeaders = new ArrayList<>();
-        for (String each : resultSet.getColumnNames()) {
-            queryHeaders.add(new QueryHeader("", "", each, each, Types.CHAR, 
"CHAR", 255, 0, false, false, false, false));
-        }
-        return new QueryResponseHeader(queryHeaders);
-    }
-    
-    @Override
-    public boolean next() {
-        return resultSet.next();
-    }
-    
-    @Override
-    public QueryResponseRow getRowData() {
-        Collection<Object> rowData = resultSet.getRowData();
-        List<QueryResponseCell> result = new ArrayList<>(rowData.size());
-        for (Object each : rowData) {
-            result.add(new QueryResponseCell(Types.CHAR, each));
-        }
-        return new QueryResponseRow(result);
-    }
-}
diff --git 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandlerFactory.java
 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandlerFactory.java
index 5527bd0ca06..85b581b52b4 100644
--- 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandlerFactory.java
+++ 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandlerFactory.java
@@ -19,10 +19,7 @@ package 
org.apache.shardingsphere.proxy.backend.handler.distsql.rql;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import 
org.apache.shardingsphere.distsql.handler.resultset.DatabaseDistSQLResultSet;
-import org.apache.shardingsphere.distsql.handler.resultset.DistSQLResultSet;
 import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 
@@ -40,15 +37,6 @@ public final class RQLBackendHandlerFactory {
      * @return RDL backend handler
      */
     public static ProxyBackendHandler newInstance(final RQLStatement 
sqlStatement, final ConnectionSession connectionSession) {
-        // TODO remove this judgment after the refactoring of DistSQLResultSet 
is completed
-        if (TypedSPILoader.contains(DistSQLResultSet.class, 
sqlStatement.getClass().getName())) {
-            return newInstanceByDistSQLResultSet(sqlStatement, 
connectionSession);
-        }
         return new RQLBackendHandler<>(sqlStatement, connectionSession);
     }
-    
-    private static ProxyBackendHandler newInstanceByDistSQLResultSet(final 
RQLStatement sqlStatement, final ConnectionSession connectionSession) {
-        DistSQLResultSet resultSet = 
TypedSPILoader.getService(DistSQLResultSet.class, 
sqlStatement.getClass().getName());
-        return new RQLResultSetBackendHandler(sqlStatement, connectionSession, 
(DatabaseDistSQLResultSet) resultSet);
-    }
 }
diff --git 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLResultSetBackendHandler.java
 
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLResultSetBackendHandler.java
deleted file mode 100644
index bdb7e7d82ad..00000000000
--- 
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLResultSetBackendHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.proxy.backend.handler.distsql.rql;
-
-import 
org.apache.shardingsphere.distsql.handler.resultset.DatabaseDistSQLResultSet;
-import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import 
org.apache.shardingsphere.proxy.backend.handler.DatabaseRequiredBackendHandler;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * RQL result set backend handler.
- * TODO remove after RQLBackendHandler is done
- */
-public final class RQLResultSetBackendHandler extends 
DatabaseRequiredBackendHandler<RQLStatement> {
-    
-    private final DatabaseDistSQLResultSet resultSet;
-    
-    public RQLResultSetBackendHandler(final RQLStatement sqlStatement, final 
ConnectionSession connectionSession, final DatabaseDistSQLResultSet resultSet) {
-        super(sqlStatement, connectionSession);
-        this.resultSet = resultSet;
-    }
-    
-    @Override
-    protected ResponseHeader execute(final String databaseName, final 
RQLStatement sqlStatement) {
-        resultSet.init(ProxyContext.getInstance().getDatabase(databaseName), 
sqlStatement);
-        List<QueryHeader> queryHeaders = resultSet.getColumnNames().stream()
-                .map(each -> new QueryHeader(databaseName, "", each, each, 
Types.CHAR, "CHAR", 255, 0, false, false, false, 
false)).collect(Collectors.toList());
-        return new QueryResponseHeader(queryHeaders);
-    }
-    
-    @Override
-    public boolean next() {
-        return resultSet.next();
-    }
-    
-    @Override
-    public QueryResponseRow getRowData() {
-        Collection<Object> rowData = resultSet.getRowData();
-        List<QueryResponseCell> result = new ArrayList<>(rowData.size());
-        for (Object each : rowData) {
-            result.add(new QueryResponseCell(Types.CHAR, each));
-        }
-        return new QueryResponseRow(result);
-    }
-}
diff --git 
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLResultSetBackendHandlerTest.java
 
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLResultSetBackendHandlerTest.java
deleted file mode 100644
index 22755130f94..00000000000
--- 
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLResultSetBackendHandlerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.proxy.backend.handler.distsql.rql;
-
-import 
org.apache.shardingsphere.distsql.handler.resultset.DatabaseDistSQLResultSet;
-import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
-import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.sql.Types;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public final class RQLResultSetBackendHandlerTest extends ProxyContextRestorer 
{
-    
-    @Before
-    public void setUp() {
-        MetaDataContexts metaDataContexts = mock(MetaDataContexts.class, 
RETURNS_DEEP_STUBS);
-        ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
-        
when(database.getRuleMetaData()).thenReturn(mock(ShardingSphereRuleMetaData.class));
-        
when(metaDataContexts.getMetaData().getDatabases()).thenReturn(Collections.singletonMap("test",
 database));
-        
when(metaDataContexts.getMetaData().containsDatabase("test")).thenReturn(true);
-        ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
-        
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
-        ProxyContext.init(contextManager);
-    }
-    
-    @Test
-    public void assertExecute() {
-        DatabaseDistSQLResultSet resultSet = 
mock(DatabaseDistSQLResultSet.class);
-        when(resultSet.getColumnNames()).thenReturn(Arrays.asList("foo", 
"bar"));
-        RQLResultSetBackendHandler handler = new 
RQLResultSetBackendHandler(mock(RQLStatement.class), 
mock(ConnectionSession.class), resultSet);
-        ResponseHeader responseHeader = handler.execute("test", 
mock(RQLStatement.class));
-        assertThat(((QueryResponseHeader) 
responseHeader).getQueryHeaders().size(), is(2));
-        assertQueryHeader(((QueryResponseHeader) 
responseHeader).getQueryHeaders().get(0), "foo");
-        assertQueryHeader(((QueryResponseHeader) 
responseHeader).getQueryHeaders().get(1), "bar");
-    }
-    
-    private void assertQueryHeader(final QueryHeader queryHeader, final String 
expectedColumnLabel) {
-        assertThat(queryHeader.getSchema(), is("test"));
-        assertThat(queryHeader.getTable(), is(""));
-        assertThat(queryHeader.getColumnLabel(), is(expectedColumnLabel));
-        assertThat(queryHeader.getColumnName(), is(expectedColumnLabel));
-        assertThat(queryHeader.getColumnType(), is(Types.CHAR));
-        assertThat(queryHeader.getColumnTypeName(), is("CHAR"));
-        assertThat(queryHeader.getColumnLength(), is(255));
-        assertThat(queryHeader.getDecimals(), is(0));
-        assertFalse(queryHeader.isSigned());
-        assertFalse(queryHeader.isPrimaryKey());
-        assertFalse(queryHeader.isNotNull());
-        assertFalse(queryHeader.isAutoIncrement());
-    }
-    
-    @Test
-    public void assertGetRowData() {
-        DatabaseDistSQLResultSet resultSet = 
mock(DatabaseDistSQLResultSet.class);
-        when(resultSet.getRowData()).thenReturn(Arrays.asList("foo_value", 
"bar_value"));
-        RQLResultSetBackendHandler handler = new 
RQLResultSetBackendHandler(mock(RQLStatement.class), 
mock(ConnectionSession.class), resultSet);
-        handler.execute("test", mock(RQLStatement.class));
-        Collection<Object> rowData = handler.getRowData().getData();
-        assertThat(rowData.size(), is(2));
-        assertTrue(rowData.contains("foo_value"));
-        assertTrue(rowData.contains("bar_value"));
-    }
-}

Reply via email to