Skip to content

Commit

Permalink
Core: Serialize null when there is no current snapshot (#11560)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko authored Nov 18, 2024
1 parent 97542ab commit bf8d25f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,11 @@ public static void toJson(TableMetadata metadata, JsonGenerator generator) throw
// write properties map
JsonUtil.writeStringMap(PROPERTIES, metadata.properties(), generator);

generator.writeNumberField(
CURRENT_SNAPSHOT_ID,
metadata.currentSnapshot() != null ? metadata.currentSnapshot().snapshotId() : -1);
if (metadata.currentSnapshot() != null) {
generator.writeNumberField(CURRENT_SNAPSHOT_ID, metadata.currentSnapshot().snapshotId());
} else {
generator.writeNullField(CURRENT_SNAPSHOT_ID);
}

toJson(metadata.refs(), generator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void roundTripSerde() {
+ " \"fields\" : [ ]\n"
+ " } ],\n"
+ " \"properties\" : { },\n"
+ " \"current-snapshot-id\" : -1,\n"
+ " \"current-snapshot-id\" : null,\n"
+ " \"refs\" : { },\n"
+ " \"snapshots\" : [ ],\n"
+ " \"statistics\" : [ ],\n"
Expand Down Expand Up @@ -180,7 +180,7 @@ public void roundTripSerdeWithConfig() {
+ " \"fields\" : [ ]\n"
+ " } ],\n"
+ " \"properties\" : { },\n"
+ " \"current-snapshot-id\" : -1,\n"
+ " \"current-snapshot-id\" : null,\n"
+ " \"refs\" : { },\n"
+ " \"snapshots\" : [ ],\n"
+ " \"statistics\" : [ ],\n"
Expand Down Expand Up @@ -283,7 +283,7 @@ public void roundTripSerdeWithCredentials() {
+ " \"fields\" : [ ]\n"
+ " } ],\n"
+ " \"properties\" : { },\n"
+ " \"current-snapshot-id\" : -1,\n"
+ " \"current-snapshot-id\" : null,\n"
+ " \"refs\" : { },\n"
+ " \"snapshots\" : [ ],\n"
+ " \"statistics\" : [ ],\n"
Expand Down

0 comments on commit bf8d25f

Please sign in to comment.