You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Piotr Bojko (JIRA)" <ji...@apache.org> on 2017/09/28 12:30:00 UTC

[jira] [Created] (CALCITE-1993) Possible bug - NPE when using H2

Piotr Bojko created CALCITE-1993:
------------------------------------

             Summary: Possible bug - NPE when using H2
                 Key: CALCITE-1993
                 URL: https://issues.apache.org/jira/browse/CALCITE-1993
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.13.0
         Environment: JIRA Container. Developed code is part of JIRA addon.
            Reporter: Piotr Bojko
            Assignee: Julian Hyde


I've receiving NPE When using Calcite. My code is as follows


{code:java}
@Autowired
public CalciteBootstrap(DatasourceProvider datasourceProvider) throws SQLException {
    this.datasource = datasourceProvider.fetchDatasource();
    log.debug("Datasource fetched - {}", datasource);
    this.connection = createRootSchema();
    this.schema = JdbcSchema.create(connection.getRootSchema(), "PUBLIC", datasource, null, null);

    connection.getRootSchema().add("jira", schema);
    connection.createStatement().executeQuery("select * from jira.PROJECT_KEY");
}

private CalciteConnection createRootSchema() {
    try {
        Class.forName("org.apache.calcite.jdbc.Driver");
        Properties info = new Properties();
        info.setProperty("lex", "JAVA");
        Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
        CalciteConnection calciteConnection
                  = connection.unwrap(CalciteConnection.class);
        return calciteConnection;
    } catch (SQLException | ClassNotFoundException ex) {
        throw new RuntimeException(ex);
    }
}

{code}
And NPE:


{noformat}
[INFO] [talledLocalContainer] java.sql.SQLException: Error while executing SQL "select * from jira.PROJECT_KEY": null
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
[INFO] [talledLocalContainer]   at com.codedoers.jira.smartql.QueryController.request(QueryController.java:23)
...
[INFO] [talledLocalContainer] Caused by: java.lang.NullPointerException
[INFO] [talledLocalContainer]   at Baz.bind(Unknown Source)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:335)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:294)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalciteMetaImpl._createIterable(CalciteMetaImpl.java:559)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:550)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:67)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:44)
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:630)
[INFO] [talledLocalContainer]   at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:607)
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
[INFO] [talledLocalContainer]   at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
[INFO] [talledLocalContainer]   ... 240 more
{noformat}

I am developing an addon for JIRA, hence the container is JIRA. DB is H2. I am borrowing JIRAs datasource for Calcite.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)