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

NullPointerException when executing JdbcAggregate implement method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0-incubating
    • 1.2.0-incubating
    • None
    • 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(); }

      }
      }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: