You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "JD Zheng (JIRA)" <ji...@apache.org> on 2017/05/22 18:55:04 UTC
[jira] [Created] (CALCITE-1801) RelRunners connection
garbage-collected prematurely
JD Zheng created CALCITE-1801:
---------------------------------
Summary: RelRunners connection garbage-collected prematurely
Key: CALCITE-1801
URL: https://issues.apache.org/jira/browse/CALCITE-1801
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.13.0
Environment: osx 10.11.6, JavaSE-1.8, junit-4.12
Reporter: JD Zheng
Assignee: Julian Hyde
Priority: Minor
I am using RelRunners to execute pre-built relnode tree. It works perfectly when I put the following code in the junit class:
protected String execute(RelNode rel) {
try (final PreparedStatement preparedStatement = RelRunners.run(rel)) {
final ResultSet resultSet = preparedStatement.executeQuery();
return printResult(resultSet, true);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
However,if I put these code inside a src class, the returned resultSet is closed.
More interestingly, if I expand the RelRunners.run() in the method like this:
public static ResultSet execute(RelNode rel) {
/*
try (final PreparedStatement preparedStatement = RelRunners.run(rel)) {
return preparedStatement.executeQuery();
} catch (SQLException e) {
throw new AQLExecuteErrorException(e);
}
*/
try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
final RelRunner runner = connection.unwrap(RelRunner.class);
PreparedStatement preparedStatement = runner.prepare(rel);
return preparedStatement.executeQuery();
} catch (SQLException e) {
throw new AQLExecuteErrorException(e);
}
}
It works again.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)