Fly-Style commented on code in PR #18805:
URL: https://github.com/apache/druid/pull/18805#discussion_r2586144561
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/JdbcQueryTest.java:
##########
@@ -145,84 +124,91 @@ public void testJdbcMetadata()
druidTables.add(table);
}
LOG.info("'druid' schema tables %s", druidTables);
- // maybe more tables than this, but at least should have these
- Assert.assertTrue(
- druidTables.containsAll(ImmutableList.of("twitterstream",
"wikipedia", WIKIPEDIA_DATA_SOURCE))
+ // maybe more tables than this, but at least should have @tableName
+ Assertions.assertTrue(
+ druidTables.containsAll(ImmutableList.of(tableName))
);
Set<String> wikiColumns = new HashSet<>();
- ResultSet columnsMetadata = metadata.getColumns("druid", "druid",
WIKIPEDIA_DATA_SOURCE, null);
+ ResultSet columnsMetadata = metadata.getColumns("druid", "druid",
tableName, null);
while (columnsMetadata.next()) {
final String column = columnsMetadata.getString(4);
wikiColumns.add(column);
}
- LOG.info("'%s' columns %s", WIKIPEDIA_DATA_SOURCE, wikiColumns);
+ LOG.info("'%s' columns %s", tableName, wikiColumns);
// a lot more columns than this, but at least should have these
- Assert.assertTrue(
- wikiColumns.containsAll(ImmutableList.of("added", "city", "delta",
"language"))
+ Assertions.assertTrue(
+ wikiColumns.containsAll(ImmutableList.of("__time", "item",
"value"))
);
}
catch (SQLException throwables) {
- Assert.fail(throwables.getMessage());
+ Assertions.fail(throwables.getMessage());
}
}
}
@Test
public void testJdbcStatementQuery()
{
+ String query = StringUtils.format(QUERY_TEMPLATE, tableName, "1000");
for (String url : connections) {
try (Connection connection = DriverManager.getConnection(url,
connectionProperties)) {
try (Statement statement = connection.createStatement()) {
- final ResultSet resultSet = statement.executeQuery(QUERY);
+ final ResultSet resultSet = statement.executeQuery(query);
int resultRowCount = 0;
while (resultSet.next()) {
resultRowCount++;
LOG.info("%s,%s,%s", resultSet.getString(1), resultSet.getLong(2),
resultSet.getLong(3));
}
- Assert.assertEquals(resultRowCount, 10);
+ Assertions.assertEquals(7, resultRowCount);
resultSet.close();
}
}
catch (SQLException throwables) {
- Assert.fail(throwables.getMessage());
+ Assertions.fail(throwables.getMessage());
}
}
}
@Test
public void testJdbcPrepareStatementQuery()
{
+ String query = StringUtils.format(QUERY_TEMPLATE, tableName, "?");
for (String url : connections) {
try (Connection connection = DriverManager.getConnection(url,
connectionProperties)) {
- try (PreparedStatement statement =
connection.prepareStatement(QUERY_PARAMETERIZED)) {
- statement.setString(1, "en");
+ try (PreparedStatement statement = connection.prepareStatement(query))
{
+ statement.setLong(1, 1000);
final ResultSet resultSet = statement.executeQuery();
int resultRowCount = 0;
while (resultSet.next()) {
resultRowCount++;
LOG.info("%s,%s,%s", resultSet.getString(1), resultSet.getLong(2),
resultSet.getLong(3));
}
- Assert.assertEquals(resultRowCount, 10);
+ Assertions.assertEquals(7, resultRowCount);
resultSet.close();
}
}
catch (SQLException throwables) {
- Assert.fail(throwables.getMessage());
+ Assertions.fail(throwables.getMessage());
}
}
}
- @Test(expectedExceptions = AvaticaSqlException.class,
expectedExceptionsMessageRegExp = ".* No value bound for parameter \\(position
\\[1]\\)")
- public void testJdbcPrepareStatementQueryMissingParameters() throws
SQLException
+ @Test
+ public void testJdbcPrepareStatementQueryMissingParameters()
{
+ String query = StringUtils.format(QUERY_TEMPLATE, tableName, "?");
for (String url : connections) {
try (Connection connection = DriverManager.getConnection(url,
connectionProperties);
- PreparedStatement statement =
connection.prepareStatement(QUERY_PARAMETERIZED);
+ PreparedStatement statement = connection.prepareStatement(query);
ResultSet resultSet = statement.executeQuery()) {
// This won't actually run as we expect the exception to be thrown
before it gets here
throw new IllegalStateException(resultSet.toString());
Review Comment:
Good catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]