linghengqian commented on code in PR #37778:
URL: https://github.com/apache/shardingsphere/pull/37778#discussion_r2706736586


##########
jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/distsql/DistSQLResultSet.java:
##########
@@ -0,0 +1,265 @@
+/*
+ * 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.driver.executor.engine.distsql;
+
+import com.google.common.base.Preconditions;
+import 
org.apache.shardingsphere.driver.jdbc.unsupported.AbstractUnsupportedGeneratedKeysResultSet;
+import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.nio.charset.StandardCharsets;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * DistSQL result set.
+ */
+public final class DistSQLResultSet extends 
AbstractUnsupportedGeneratedKeysResultSet {
+    
+    private final List<String> columnNames;
+    
+    private final Iterator<LocalDataQueryResultRow> rows;
+    
+    private final Statement statement;
+    
+    private LocalDataQueryResultRow currentRow;
+    
+    private boolean closed;
+    
+    public DistSQLResultSet(final Collection<String> columnNames, final 
Collection<LocalDataQueryResultRow> rows, final Statement statement) {
+        this.columnNames = new ArrayList<>(columnNames);
+        this.rows = rows.iterator();
+        this.statement = statement;
+    }
+    
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+    
+    @Override
+    public boolean next() {
+        if (closed || !rows.hasNext()) {
+            currentRow = null;
+            return false;
+        }
+        currentRow = rows.next();
+        return true;
+    }
+    
+    @Override
+    public void close() {
+        closed = true;
+    }
+    
+    @Override
+    public ResultSetMetaData getMetaData() {
+        checkState();
+        return new DistSQLResultSetMetaData(columnNames);
+    }
+    
+    @Override
+    public boolean wasNull() {
+        checkState();
+        return false;
+    }
+    
+    @Override
+    public String getString(final int columnIndex) {
+        checkStateForGetData();
+        Object value = currentRow.getCell(columnIndex);
+        return null == value ? null : value.toString();
+    }
+    
+    @Override
+    public String getString(final String columnLabel) {
+        return getString(findColumn(columnLabel));
+    }
+    
+    @Override
+    public String getNString(final int columnIndex) {
+        return getString(columnIndex);
+    }
+    
+    @Override
+    public String getNString(final String columnLabel) {
+        return getString(columnLabel);
+    }
+    
+    @Override
+    public byte getByte(final int columnIndex) {
+        checkStateForGetData();
+        String value = getString(columnIndex);
+        return null == value ? 0 : Byte.parseByte(value);
+    }
+    
+    @Override
+    public byte getByte(final String columnLabel) {
+        return getByte(findColumn(columnLabel));
+    }
+    
+    @Override
+    public short getShort(final int columnIndex) {
+        checkStateForGetData();
+        String value = getString(columnIndex);
+        return null == value ? 0 : Short.parseShort(value);
+    }
+    
+    @Override
+    public short getShort(final String columnLabel) {
+        return getShort(findColumn(columnLabel));
+    }
+    
+    @Override
+    public int getInt(final int columnIndex) {
+        checkStateForGetData();
+        String value = getString(columnIndex);
+        return null == value ? 0 : Integer.parseInt(value);
+    }
+    
+    @Override
+    public int getInt(final String columnLabel) {
+        return getInt(findColumn(columnLabel));
+    }
+    
+    @Override
+    public long getLong(final int columnIndex) {
+        checkStateForGetData();
+        String value = getString(columnIndex);
+        return null == value ? 0L : Long.parseLong(value);
+    }
+    
+    @Override
+    public long getLong(final String columnLabel) {
+        return getLong(findColumn(columnLabel));
+    }
+    
+    @Override
+    public float getFloat(final int columnIndex) {
+        checkStateForGetData();
+        String value = getString(columnIndex);
+        return null == value ? 0F : Float.parseFloat(value);

Review Comment:
   I can't think of any situation where this exception would be thrown here. It 
seems to be a hallucination of copilot.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to