Skip to content

Commit

Permalink
[core] Add ignoreUnknown to Snapshot (#3202)
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi authored Apr 12, 2024
1 parent 5c78579 commit 0d40e68
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions paimon-core/src/main/java/org/apache/paimon/Snapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonGetter;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonProperty;

Expand Down Expand Up @@ -64,6 +65,7 @@
* there is no compatibility issue.
* </ul>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Snapshot {

public static final long FIRST_SNAPSHOT_ID = 1;
Expand Down Expand Up @@ -142,6 +144,8 @@ public class Snapshot {
private final long timeMillis;

@JsonProperty(FIELD_LOG_OFFSETS)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Nullable
private final Map<Integer, Long> logOffsets;

// record count of all changes occurred in this snapshot
Expand All @@ -159,6 +163,7 @@ public class Snapshot {
// record count of all changelog produced in this snapshot
// null for paimon <= 0.3
@JsonProperty(FIELD_CHANGELOG_RECORD_COUNT)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Nullable
private final Long changelogRecordCount;

Expand All @@ -167,6 +172,7 @@ public class Snapshot {
// null if there is no watermark in new committing, and the previous snapshot does not have a
// watermark
@JsonProperty(FIELD_WATERMARK)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Nullable
private final Long watermark;

Expand Down
44 changes: 44 additions & 0 deletions paimon-core/src/test/java/org/apache/paimon/SnapshotTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.paimon;

import org.junit.jupiter.api.Test;

class SnapshotTest {

@Test
public void testJsonIgnoreProperties() {
Snapshot.fromJson(
"{\n"
+ " \"version\" : 3,\n"
+ " \"id\" : 5,\n"
+ " \"schemaId\" : 0,\n"
+ " \"baseManifestList\" : null,\n"
+ " \"deltaManifestList\" : null,\n"
+ " \"changelogManifestList\" : null,\n"
+ " \"commitUser\" : null,\n"
+ " \"commitIdentifier\" : 0,\n"
+ " \"commitKind\" : \"APPEND\",\n"
+ " \"timeMillis\" : 1234,\n"
+ " \"totalRecordCount\" : null,\n"
+ " \"deltaRecordCount\" : null,\n"
+ " \"unknownKey\" : 22222\n"
+ "}");
}
}

0 comments on commit 0d40e68

Please sign in to comment.