slinkydeveloper commented on a change in pull request #18427:
URL: https://github.com/apache/flink/pull/18427#discussion_r791013866



##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/ResolvedCatalogTableJsonSerializer.java
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.flink.table.planner.plan.nodes.exec.serde;
+
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.CatalogBaseTable;
+import org.apache.flink.table.catalog.ExternalCatalogTable;
+import org.apache.flink.table.catalog.ResolvedCatalogTable;
+
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.SerializerProvider;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
+import java.io.IOException;
+
+/**
+ * This serializer can be configured via an attribute to serialize or not the 
options and comments,
+ * setting the attribute {@link #SERIALIZE_OPTIONS} to {@code true} or {@code 
false}.
+ */
+class ResolvedCatalogTableJsonSerializer extends 
StdSerializer<ResolvedCatalogTable> {
+    private static final long serialVersionUID = 1L;
+
+    static final String SERIALIZE_OPTIONS = "serialize_options";
+
+    public static final String RESOLVED_SCHEMA = "resolvedSchema";
+    public static final String PARTITION_KEYS = "partitionKeys";
+    public static final String OPTIONS = "options";
+    public static final String COMMENT = "comment";
+
+    public ResolvedCatalogTableJsonSerializer() {
+        super(ResolvedCatalogTable.class);
+    }
+
+    @Override
+    public void serialize(
+            ResolvedCatalogTable resolvedCatalogTable,
+            JsonGenerator jsonGenerator,
+            SerializerProvider serializerProvider)
+            throws IOException {
+        // Thia should never happen anyway, but we keep this assertion for 
sanity check
+        assert resolvedCatalogTable.getTableKind() == 
CatalogBaseTable.TableKind.TABLE;
+
+        boolean serializeOptions =

Review comment:
       I tried to parametrize the ser/de itself, as one might use it in another 
context for another purpose, and might have a different rationale behind 
serializing or not the options.
   
   To unblock the discussion, I factored out in a static method the 
serialization code, and from `ContextResolvedTableJsonSerializer` i call that 
method directly. But I still keep this option, as it's useful for testing and 
might be useful for setting this serializer option from an higher level 
(similar to how you define data time formats in jackson today)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to