tsreaper commented on code in PR #428:
URL: https://github.com/apache/flink-table-store/pull/428#discussion_r1045401837
##########
flink-table-store-core/src/test/java/org/apache/flink/table/store/table/ChangelogWithKeyFileStoreTableTest.java:
##########
@@ -615,6 +618,69 @@ public void testIncrementalScanOverwrite() throws
Exception {
.isNotEqualTo(splits0.get(0).files().get(0).fileName());
}
+ @Test
+ public void testAuditLog() throws Exception {
+ FileStoreTable table =
+ createFileStoreTable(
+ conf -> conf.set(CoreOptions.CHANGELOG_PRODUCER,
ChangelogProducer.INPUT));
+ TableWrite write = table.newWrite(commitUser);
+ TableCommit commit = table.newCommit(commitUser);
+ write.write(rowDataWithKind(RowKind.INSERT, 1, 10, 100L));
+ write.write(rowDataWithKind(RowKind.INSERT, 2, 20, 200L));
+ commit.commit(0, write.prepareCommit(true, 0));
+
+ AuditLogTable auditLogTable = new AuditLogTable(table);
+ RowRowConverter converter =
+ RowRowConverter.create(
+ DataTypes.ROW(
+ DataTypes.STRING(),
+ DataTypes.INT(),
+ DataTypes.INT(),
+ DataTypes.BIGINT()));
+ Function<RowData, String> rowDataToString = row ->
converter.toExternal(row).toString();
+ PredicateBuilder predicateBuilder = new
PredicateBuilder(auditLogTable.rowType());
+
+ // Read all
+ TableScan scan = auditLogTable.newScan();
+ TableRead read = auditLogTable.newRead();
+ List<String> result = getResult(read, scan.plan().splits(),
rowDataToString);
+ assertThat(result).containsExactlyInAnyOrder("+I[+I, 2, 20, 200]",
"+I[+I, 1, 10, 100]");
+
+ // Read by filter row kind
+ Predicate rowKindEqual = predicateBuilder.equal(0,
StringData.fromString("+I"));
+ scan = auditLogTable.newScan().withFilter(rowKindEqual);
+ read = auditLogTable.newRead().withFilter(rowKindEqual);
+ result = getResult(read, scan.plan().splits(), rowDataToString);
+ assertThat(result).containsExactlyInAnyOrder("+I[+I, 2, 20, 200]",
"+I[+I, 1, 10, 100]");
+
+ // Read by filter
+ scan = auditLogTable.newScan().withFilter(predicateBuilder.equal(2,
10));
+ read = auditLogTable.newRead().withFilter(predicateBuilder.equal(2,
10));
+ result = getResult(read, scan.plan().splits(), rowDataToString);
+ assertThat(result).containsExactlyInAnyOrder("+I[+I, 1, 10, 100]");
Review Comment:
There is only one snapshot and one file, so these tests are actually
useless. Create at least 2 files so the predicate actually filters something
when scanning files.
--
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]