Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ public KeyValue getResult() {
} else if (kvs.size() == 2) {
KeyValue before = kvs.get(0);
KeyValue after = kvs.get(1);
if (after.level() == AFTER_LEVEL) {
if (!valueAndRowKindEquals(before, after)) {
if (!valueAndRowKindEquals(before, after)) {
if (after.level() == AFTER_LEVEL) {
toReturn = after;
} else if (after.level() == BEFORE_LEVEL) {
toReturn = before;
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,31 @@ public void testIncrementScanMode() throws Exception {
Row.of("+I", 2, "B"), Row.of("-D", 2, "B"), Row.of("+I", 3, "C"));
}

@Test
public void testIncrementScanModeWithInsertOverwrite() throws Exception {
sql("CREATE TABLE test_scan_mode (id INT PRIMARY KEY NOT ENFORCED, v STRING)");

// snapshot 1
sql("INSERT OVERWRITE test_scan_mode VALUES (1, 'A'), (1, 'B'), (1, 'C')");
// snapshot 2
sql("INSERT OVERWRITE test_scan_mode VALUES (1, 'C'), (1, 'D')");

List<Row> result =
sql(
"SELECT * FROM `test_scan_mode$audit_log` "
+ "/*+ OPTIONS('incremental-between'='1,2','incremental-between-scan-mode'='diff') */");
assertThat(result).containsExactlyInAnyOrder(Row.of("+I", 1, "D"));

// snapshot 3
sql("INSERT OVERWRITE test_scan_mode VALUES (1, 'D')");

result =
sql(
"SELECT * FROM `test_scan_mode$audit_log` "
+ "/*+ OPTIONS('incremental-between'='2,2','incremental-between-scan-mode'='diff') */");
assertThat(result).isEmpty();
}

@Test
public void testAuditLogTableWithComputedColumn() throws Exception {
sql("CREATE TABLE test_table (a int, b int, c AS a + b);");
Expand Down