Hi,
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.
Has anyone seen this behavior before or has any insights? Thanks,
-JD