Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-event-decoder-vtt #253

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -116,12 +116,12 @@ private Payload convertPayload(io.tabular.iceberg.connect.events.Payload payload
pay.commitId(),
TableReference.of(catalogName, pay.tableName().toIdentifier()),
pay.snapshotId(),
OffsetDateTime.ofInstant(Instant.ofEpochMilli(pay.vtts()), ZoneOffset.UTC));
pay.vtts() == null ? null : OffsetDateTime.ofInstant(Instant.ofEpochMilli(pay.vtts()), ZoneOffset.UTC));
} else if (payload instanceof CommitCompletePayload) {
CommitCompletePayload pay = (CommitCompletePayload) payload;
return new CommitComplete(
pay.commitId(),
OffsetDateTime.ofInstant(Instant.ofEpochMilli(pay.vtts()), ZoneOffset.UTC));
pay.vtts() == null ? null : OffsetDateTime.ofInstant(Instant.ofEpochMilli(pay.vtts()), ZoneOffset.UTC));
} else {
throw new IllegalStateException(
String.format("Unknown event payload: %s", payload.getSchema()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,28 @@ public void testCommitTableBecomesCommitToTable() {
assertThat(payload.tableReference().identifier()).isEqualTo(TableIdentifier.of("db", "tbl"));
}

@Test
public void testCommitTableBecomesCommitToTableNullVtts() {
io.tabular.iceberg.connect.events.Event event =
new io.tabular.iceberg.connect.events.Event(
"cg-connector",
EventType.COMMIT_TABLE,
new CommitTablePayload(
commitId, new TableName(Collections.singletonList("db"), "tbl"), 1L, null));

byte[] data = io.tabular.iceberg.connect.events.Event.encode(event);

Event result = eventDecoder.decode(data);
assertThat(event.groupId()).isEqualTo("cg-connector");
assertThat(result.type()).isEqualTo(PayloadType.COMMIT_TO_TABLE);
assertThat(result.payload()).isInstanceOf(CommitToTable.class);
CommitToTable payload = (CommitToTable) result.payload();

assertThat(payload.commitId()).isEqualTo(commitId);
assertThat(payload.snapshotId()).isEqualTo(1L);
assertThat(payload.validThroughTs()).isNull();
tabmatfournier marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void testCommitCompleteBecomesCommitCompleteSerialization() {
io.tabular.iceberg.connect.events.Event event =
Expand All @@ -255,4 +277,19 @@ public void testCommitCompleteBecomesCommitCompleteSerialization() {
assertThat(payload.validThroughTs())
.isEqualTo(OffsetDateTime.ofInstant(Instant.ofEpochMilli(2L), ZoneOffset.UTC));
}

@Test
public void testCommitCompleteBecomesCommitCompleteSerializationNullVtts() {
io.tabular.iceberg.connect.events.Event event =
new io.tabular.iceberg.connect.events.Event(
"cg-connector", EventType.COMMIT_COMPLETE, new CommitCompletePayload(commitId, null));

byte[] data = io.tabular.iceberg.connect.events.Event.encode(event);

Event result = eventDecoder.decode(data);
assertThat(result.type()).isEqualTo(PayloadType.COMMIT_COMPLETE);
assertThat(result.payload()).isInstanceOf(CommitComplete.class);
CommitComplete payload = (CommitComplete) result.payload();
assertThat(payload.validThroughTs()).isNull();
tabmatfournier marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading