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

duanzhengqiang 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 ef2c1d70af8 Fix federated query LocalDateTime conversion (#30935)
ef2c1d70af8 is described below

commit ef2c1d70af835d421f8dfb9fd6fc91ecc40dbba4
Author: niu niu <[email protected]>
AuthorDate: Wed Apr 17 15:16:37 2024 +0800

    Fix federated query LocalDateTime conversion (#30935)
---
 .../sqlfederation/executor/enumerator/JDBCRowEnumerator.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java
 
b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java
index b639f6917d7..033d1979648 100644
--- 
a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java
+++ 
b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java
@@ -21,11 +21,14 @@ import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import org.apache.calcite.linq4j.Enumerator;
 import 
org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
+import 
org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.util.ResultSetUtils;
 import org.apache.shardingsphere.infra.merge.result.MergedResult;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.wrapper.SQLWrapperException;
 
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
 import java.util.Collection;
 
 /**
@@ -64,11 +67,16 @@ public final class JDBCRowEnumerator implements 
Enumerator<Object> {
     private void setCurrentRow() throws SQLException {
         Object[] rowValues = new Object[metaData.getColumnCount()];
         for (int i = 0; i < metaData.getColumnCount(); i++) {
-            rowValues[i] = queryResult.getValue(i + 1, Object.class);
+            rowValues[i] = getValue(i);
         }
         this.currentRow = 1 == metaData.getColumnCount() ? rowValues[0] : 
rowValues;
     }
     
+    private Object getValue(final int index) throws SQLException {
+        Object result = queryResult.getValue(index + 1, Object.class);
+        return result instanceof LocalDateTime ? 
ResultSetUtils.convertValue(result, Timestamp.class) : result;
+    }
+    
     @Override
     public void reset() {
     }

Reply via email to