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

libenchao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 3d39fdcee2 [CALCITE-5243] `SELECT NULL AS C` causes 
NoSuchMethodException: java.sql.ResultSet.getVoid(int)
3d39fdcee2 is described below

commit 3d39fdcee28a04cfddad3bcb427eb78f4767ca0d
Author: wumou.wm <[email protected]>
AuthorDate: Sat Aug 27 20:26:55 2022 +0800

    [CALCITE-5243] `SELECT NULL AS C` causes NoSuchMethodException: 
java.sql.ResultSet.getVoid(int)
    
    This closes #2886
---
 .../calcite/adapter/jdbc/JdbcToEnumerableConverter.java     |  4 ++++
 .../test/java/org/apache/calcite/test/JdbcAdapterTest.java  | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcToEnumerableConverter.java
 
b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcToEnumerableConverter.java
index 313a896ec1..8f02d040ef 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcToEnumerableConverter.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcToEnumerableConverter.java
@@ -22,6 +22,7 @@ import 
org.apache.calcite.adapter.enumerable.EnumerableRelImplementor;
 import org.apache.calcite.adapter.enumerable.JavaRowFormat;
 import org.apache.calcite.adapter.enumerable.PhysType;
 import org.apache.calcite.adapter.enumerable.PhysTypeImpl;
+import org.apache.calcite.adapter.enumerable.RexImpTable;
 import org.apache.calcite.adapter.java.JavaTypeFactory;
 import org.apache.calcite.config.CalciteSystemProperty;
 import org.apache.calcite.linq4j.tree.BlockBuilder;
@@ -278,6 +279,9 @@ public class JdbcToEnumerableConverter
           java.sql.Array.class);
       source = Expressions.call(BuiltInMethod.JDBC_ARRAY_TO_LIST.method, x);
       break;
+    case NULL:
+      source = RexImpTable.NULL_EXPR;
+      break;
     default:
       source = Expressions.call(
           resultSet_, jdbcGetMethod(primitive), Expressions.constant(i + 1));
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java 
b/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
index 2b0a5aaa2e..501c2485e4 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
@@ -1093,6 +1093,19 @@ class JdbcAdapterTest {
         .runs();
   }
 
+  /**
+   * Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-5243";>[CALCITE-5243]
+   * "SELECT NULL AS C causes NoSuchMethodException: 
java.sql.ResultSet.getVoid(int)</a>. */
+  @Test void testNullSelect() {
+    final String sql = "select NULL AS C from \"days\"";
+    CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
+        .query(sql)
+        .runs()
+        .returnsCount(7)
+        .returns("C=null\nC=null\nC=null\nC=null\nC=null\nC=null\nC=null\n");
+  }
+
   /** Acquires a lock, and releases it when closed. */
   static class LockWrapper implements AutoCloseable {
     private final Lock lock;

Reply via email to