This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 0d40e68c6 [core] Add ignoreUnknown to Snapshot (#3202)
0d40e68c6 is described below
commit 0d40e68c647e0a053de18da37cafdddac8b76265
Author: Jingsong Lee <[email protected]>
AuthorDate: Fri Apr 12 17:41:26 2024 +0800
[core] Add ignoreUnknown to Snapshot (#3202)
---
.../src/main/java/org/apache/paimon/Snapshot.java | 6 +++
.../test/java/org/apache/paimon/SnapshotTest.java | 44 ++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
b/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
index 33ea8f4bb..0ac23ecf0 100644
--- a/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
+++ b/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
@@ -29,6 +29,7 @@ import org.apache.paimon.utils.JsonSerdeUtil;
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;
@@ -64,6 +65,7 @@ import java.util.Optional;
* there is no compatibility issue.
* </ul>
*/
+@JsonIgnoreProperties(ignoreUnknown = true)
public class Snapshot {
public static final long FIRST_SNAPSHOT_ID = 1;
@@ -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
@@ -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;
@@ -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;
diff --git a/paimon-core/src/test/java/org/apache/paimon/SnapshotTest.java
b/paimon-core/src/test/java/org/apache/paimon/SnapshotTest.java
new file mode 100644
index 000000000..d8266c1c6
--- /dev/null
+++ b/paimon-core/src/test/java/org/apache/paimon/SnapshotTest.java
@@ -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"
+ + "}");
+ }
+}