snuyanzin commented on code in PR #79:
URL:
https://github.com/apache/flink-connector-jdbc/pull/79#discussion_r1421097646
##########
flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/table/JdbcDynamicTableSourceITCase.java:
##########
@@ -287,65 +370,29 @@ void testLookupJoin(Caching caching) {
inputTable.getCreateQueryForFlink(getMetadata(),
"jdbc_lookup", cachingOptions));
// Create and prepare a value source
- String dataId =
- TestValuesTableFactory.registerData(
- Arrays.asList(
- Row.of(1L, "Alice"),
- Row.of(1L, "Alice"),
- Row.of(2L, "Bob"),
- Row.of(3L, "Charlie")));
- tEnv.executeSql(
- String.format(
- "CREATE TABLE value_source ( "
- + " `id` BIGINT, "
- + " `name` STRING, "
- + " `proctime` AS PROCTIME()"
- + ") WITH ("
- + " 'connector' = 'values', "
- + " 'data-id' = '%s'"
- + ")",
- dataId));
+ String dataId = TestValuesTableFactory.registerData(dataToRegister);
+ tEnv.executeSql(String.format(createTableStatement, dataId));
if (caching == Caching.ENABLE_CACHE) {
LookupCacheManager.keepCacheOnRelease(true);
}
// Execute lookup join
try {
- List<Row> collected =
- executeQuery(
- "SELECT S.id, S.name, D.id, D.timestamp6_col,
D.decimal_col FROM value_source"
- + " AS S JOIN jdbc_lookup for system_time
as of S.proctime AS D ON S.id = D.id");
-
- assertThat(collected).hasSize(3);
+ List<Row> collected = executeQuery(selectStatement);
+ int expectedSize = expectedResultSetRows.size();
- List<Row> expected =
- Arrays.asList(
- Row.of(
- 1L,
- "Alice",
- 1L,
-
truncateTime(LocalDateTime.parse("2020-01-01T15:35:00.123456")),
- BigDecimal.valueOf(100.1234)),
- Row.of(
- 1L,
- "Alice",
- 1L,
-
truncateTime(LocalDateTime.parse("2020-01-01T15:35:00.123456")),
- BigDecimal.valueOf(100.1234)),
- Row.of(
- 2L,
- "Bob",
- 2L,
-
truncateTime(LocalDateTime.parse("2020-01-01T15:36:01.123456")),
- BigDecimal.valueOf(101.1234)));
+ // check we go the expected number of rows
+ assertThat(collected)
+ .as("Actual output is not size " + expectedSize)
+ .hasSize(expectedSize);
assertThat(collected)
.as("The actual output is not a subset of the expected
set")
- .containsAll(expected);
+ .containsAll(expectedResultSetRows);
Review Comment:
This could be simplified as
```java
assertThat(collected)
.as("Actual output is not size " + expectedSize)
.hasSize(expectedSize)
.as("The actual output is not a subset of the expected set")
.containsAll(expectedResultSetRows);
```
--
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]