Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-657

NullPointerException when executing JdbcAggregate implement method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0-incubating
    • Fix Version/s: 1.2.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      When select with aggregations on identifiers, getting java.lang.NullPointerException during execution of JdbcAggregate implement method.

      Cause:
      rowtype=null instead of getRowType() is used as parameter for addSelect method

      Test:
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.Statement;
      import java.util.Properties;
      import org.hsqldb.jdbcDriver;

      public class testJdbcAggregate {

      public static void main(String[] args) {
      try {
      String hsqldbMemUrl = "jdbc:hsqldb:mem:.";
      Connection baseConnection = DriverManager.getConnection(hsqldbMemUrl);
      Statement baseStmt = baseConnection.createStatement();
      baseStmt.execute("CREATE TABLE T1 (\n"
      + "ID INTEGER,\n"
      + "VALS INTEGER)");
      baseStmt.execute("INSERT INTO T1 VALUES (1, 1)");
      baseStmt.execute("INSERT INTO T1 VALUES (2, null)");

      baseStmt.close();
      baseConnection.commit();

      Properties info = new Properties();
      info.put("model",
      "inline:"
      + "{\n"
      + " version: '1.0',\n"
      + " defaultSchema: 'BASEJDBC',\n"
      + " schemas: [\n"
      + "

      {\n" + " type: 'jdbc',\n" + " name: 'BASEJDBC',\n" + " jdbcDriver: '" + jdbcDriver.class.getName() + "',\n" + " jdbcUrl: '" + hsqldbMemUrl + "',\n" + " jdbcCatalog: null,\n" + " jdbcSchema: null\n" + " }

      \n"
      + " ]\n"
      + "}");

      Connection calciteConnection = DriverManager.getConnection(
      "jdbc:calcite:", info);

      Integer n = 1;
      ResultSet rs = calciteConnection.prepareStatement("select 10 * count(ID) from t1").executeQuery();
      while (rs.next())

      { System.out.println ("calciteRs agg_compute:" + (Long) rs.getObject(n)); n += 1; }

      rs.close();
      calciteConnection.close();

      }catch (Exception e)

      { e.printStackTrace(); }

      }
      }

        Activity

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/241f77e2 .
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.2.0-incubating (2015-04-16)

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.2.0-incubating (2015-04-16)

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            YAY Yuri Au Yong
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development