use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.CalciteConnection in project calcite by apache.
the class CsvTest method testPrepared.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1031">[CALCITE-1031]
* In prepared statement, CsvScannableTable.scan is called twice</a>. To see
* the bug, place a breakpoint in CsvScannableTable.scan, and note that it is
* called twice. It should only be called once.
*/
@Test
public void testPrepared() throws SQLException {
final Properties properties = new Properties();
properties.setProperty("caseSensitive", "true");
try (final Connection connection = DriverManager.getConnection("jdbc:calcite:", properties)) {
final CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
final Schema schema = CsvSchemaFactory.INSTANCE.create(calciteConnection.getRootSchema(), null, ImmutableMap.<String, Object>of("directory", resourcePath("sales"), "flavor", "scannable"));
calciteConnection.getRootSchema().add("TEST", schema);
final String sql = "select * from \"TEST\".\"DEPTS\" where \"NAME\" = ?";
final PreparedStatement statement2 = calciteConnection.prepareStatement(sql);
statement2.setString(1, "Sales");
final ResultSet resultSet1 = statement2.executeQuery();
Function<ResultSet, Void> expect = expect("DEPTNO=10; NAME=Sales");
expect.apply(resultSet1);
}
}
Aggregations