You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2022/12/06 02:36:19 UTC
[flink-table-store] branch master updated: [hotfix] Fix compile and use Json utils
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/flink-table-store.git
The following commit(s) were added to refs/heads/master by this push:
new 8a4f8d77 [hotfix] Fix compile and use Json utils
8a4f8d77 is described below
commit 8a4f8d77856e5cb63b1a8f0689e89cc60f475476
Author: JingsongLi <lz...@aliyun.com>
AuthorDate: Tue Dec 6 10:36:09 2022 +0800
[hotfix] Fix compile and use Json utils
---
.../flink/table/store/file/utils/JsonSerdeUtil.java | 8 ++++++++
.../flink/table/store/table/metadata/SchemasTable.java | 18 +++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/JsonSerdeUtil.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/JsonSerdeUtil.java
index b7d452ce..293d6546 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/JsonSerdeUtil.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/JsonSerdeUtil.java
@@ -69,6 +69,14 @@ public class JsonSerdeUtil {
}
}
+ public static <T> String toFlatJson(T t) {
+ try {
+ return OBJECT_MAPPER_INSTANCE.writer().writeValueAsString(t);
+ } catch (JsonProcessingException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
private static Module createTableStoreJacksonModule() {
SimpleModule module = new SimpleModule("Table store");
registerJsonObjects(module, TableSchema.class, SchemaSerializer.INSTANCE);
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/metadata/SchemasTable.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/metadata/SchemasTable.java
index a41bc345..7128c854 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/metadata/SchemasTable.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/table/metadata/SchemasTable.java
@@ -38,14 +38,12 @@ import org.apache.flink.table.types.logical.BigIntType;
import org.apache.flink.table.types.logical.RowType;
import org.apache.flink.shaded.guava30.com.google.common.collect.Iterators;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
+import java.util.Map;
import java.util.Objects;
import static org.apache.flink.table.store.file.catalog.Catalog.METADATA_TABLE_SPLITTER;
@@ -97,6 +95,11 @@ public class SchemasTable implements Table {
return new SchemasRead();
}
+ @Override
+ public Table copy(Map<String, String> dynamicOptions) {
+ return new SchemasTable(location);
+ }
+
private class SchemasScan implements TableScan {
@Override
@@ -187,14 +190,7 @@ public class SchemasTable implements Table {
}
private StringData toJson(Object obj) {
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- // Trim all spaces
- JsonNode node = objectMapper.readTree(JsonSerdeUtil.toJson(obj));
- return StringData.fromString(node.toString());
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
+ return StringData.fromString(JsonSerdeUtil.toFlatJson(obj));
}
}
}