You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/02/05 08:02:52 UTC

[GitHub] [flink] godfreyhe opened a new pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

godfreyhe opened a new pull request #14878:
URL: https://github.com/apache/flink/pull/14878


   
   
   ## What is the purpose of the change
   
   *This pr aims to support StreamExecCalc json serialization/deserialization. now we can get json plan for sql like: select a, b from MyTable where c > 0, and execute the json plan.*
   
   
   ## Brief change log
   
     - *LogicalType's serializer and deserializer should consider empty Char/VarChar/Binary/VarBinary*
     - *Support RexNode and RelDataType json serialization/deserialization*
     - *Support StreamExecCalc json serialization/deserialization*
   
   
   ## Verifying this change
   
   
   This change added tests and can be verified as follows:
   
     - *Extended LogicalTypeSerdeTest test for empty Char/VarChar/Binary/VarBinary json serialization/deserialization*
     - *Added RelDataTypeSerdeTest to verify RelDataType json serialization/deserialization*
     - *Added RexNodeSerdeTest to verify RexNode json serialization/deserialization*
     - *Added CalcJsonPlanTest to verify the json plan of calc query, Added CalcJsonPlanITCase to execute the json plan of calc query.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (**yes** / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / **not documented**)
   


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998",
       "triggerID" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "bbe20063990703285bdfa7c37958151641534426",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "bbe20063990703285bdfa7c37958151641534426",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 0e30f3541608abedd18beece54297e6815d6ae3c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998) 
   * bbe20063990703285bdfa7c37958151641534426 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r584522069



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/EnumTypes.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.functions.FunctionKind;
+import org.apache.flink.table.types.logical.TimestampKind;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.calcite.sql.fun.SqlTrimFunction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Registry of {@link Enum} classes that can be serialized to JSON.
+ *
+ * <p>Suppose you want to serialize the value {@link SqlTrimFunction.Flag#LEADING} to JSON. First,
+ * make sure that {@link SqlTrimFunction.Flag} is registered. The type will be serialized as
+ * "SYMBOL". The value will be serialized as the string "LEADING".
+ *
+ * <p>When we deserialize, we rely on the fact that the registered {@code enum} classes have
+ * distinct values. Therefore, knowing that {@code (type="SYMBOL", value="LEADING")} we can convert
+ * the string "LEADING" to the enum {@code Flag.LEADING}.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public abstract class EnumTypes {
+    private EnumTypes() {}
+
+    private static final Map<String, Enum<?>> ENUM_BY_NAME;

Review comment:
       the shortcoming of the above approach is the registered enums' names must be unique. 




----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 531cf986cd749ee5465b768121f2ffa996f20e28 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998",
       "triggerID" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "bbe20063990703285bdfa7c37958151641534426",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14040",
       "triggerID" : "bbe20063990703285bdfa7c37958151641534426",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * bbe20063990703285bdfa7c37958151641534426 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14040) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 531cf986cd749ee5465b768121f2ffa996f20e28 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987) 
   * d87084638f2714de24bfc578c88f852eda0613ee UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * d87084638f2714de24bfc578c88f852eda0613ee Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054) 
   * 0656ccf0bc8833314a41d6fcf0f0227821f8f5af UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe closed pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe closed pull request #14878:
URL: https://github.com/apache/flink/pull/14878


   


----------------------------------------------------------------
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.

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



[GitHub] [flink] wenlong88 commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
wenlong88 commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r570897982



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/FlinkDeserializationContext.java
##########
@@ -22,13 +22,17 @@
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationConfig;
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext;
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.InjectableValues;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.deser.DefaultDeserializationContext;
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.deser.DeserializerFactory;
 
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
 /** Custom JSON {@link DeserializationContext} which wraps a {@link SerdeContext}. */
 public class FlinkDeserializationContext extends DefaultDeserializationContext {
     private static final long serialVersionUID = 1L;
     private final SerdeContext serdeCtx;
+    private ObjectMapper ownerMapper;

Review comment:
       this is a typo? objectMapper?

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/EnumTypes.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.functions.FunctionKind;
+import org.apache.flink.table.types.logical.TimestampKind;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.calcite.sql.fun.SqlTrimFunction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Registry of {@link Enum} classes that can be serialized to JSON.
+ *
+ * <p>Suppose you want to serialize the value {@link SqlTrimFunction.Flag#LEADING} to JSON. First,
+ * make sure that {@link SqlTrimFunction.Flag} is registered. The type will be serialized as
+ * "SYMBOL". The value will be serialized as the string "LEADING".
+ *
+ * <p>When we deserialize, we rely on the fact that the registered {@code enum} classes have
+ * distinct values. Therefore, knowing that {@code (type="SYMBOL", value="LEADING")} we can convert
+ * the string "LEADING" to the enum {@code Flag.LEADING}.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public abstract class EnumTypes {
+    private EnumTypes() {}
+
+    private static final Map<String, Enum<?>> ENUM_BY_NAME;

Review comment:
       why should we need this? as I known the default json serialization for enum is use the name of the value.

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/JsonSerdeUtil.java
##########
@@ -44,15 +44,17 @@ public static boolean hasJsonCreatorAnnotation(Class<?> clazz) {
 
     /** Create an {@link ObjectMapper} which DeserializationContext wraps a {@link SerdeContext}. */
     public static ObjectMapper createObjectMapper(SerdeContext serdeCtx) {
+        FlinkDeserializationContext ctx =
+                new FlinkDeserializationContext(
+                        new DefaultDeserializationContext.Impl(BeanDeserializerFactory.instance),
+                        serdeCtx);
         ObjectMapper mapper =
                 new ObjectMapper(
                         null, // JsonFactory
                         null, // DefaultSerializerProvider
-                        new FlinkDeserializationContext(
-                                new DefaultDeserializationContext.Impl(
-                                        BeanDeserializerFactory.instance),
-                                serdeCtx));
+                        ctx);
         mapper.configure(MapperFeature.USE_GETTERS_AS_SETTERS, false);
+        ctx.setObjectMapper(mapper);

Review comment:
       can we prevent the cyclic dependency here? 

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/RelDataTypeJsonSerializer.java
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.planner.plan.schema.GenericRelDataType;
+import org.apache.flink.table.planner.plan.schema.RawRelDataType;
+import org.apache.flink.table.planner.plan.schema.StructuredRelDataType;
+import org.apache.flink.table.planner.plan.schema.TimeIndicatorRelDataType;
+import org.apache.flink.table.types.logical.TimestampKind;
+import org.apache.flink.table.types.logical.TypeInformationRawType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+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 org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.sql.type.ArraySqlType;
+import org.apache.calcite.sql.type.MapSqlType;
+import org.apache.calcite.sql.type.MultisetSqlType;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import java.io.IOException;
+
+/**
+ * JSON serializer for {@link RelDataType}. refer to {@link RelDataTypeJsonDeserializer} for
+ * deserializer.
+ */
+public class RelDataTypeJsonSerializer extends StdSerializer<RelDataType> {
+    private static final long serialVersionUID = 1L;
+
+    public static final String FIELD_NAME_TYPE_NAME = "typeName";
+    public static final String FIELD_NAME_FILED_NAME = "fieldName";
+    public static final String FIELD_NAME_NULLABLE = "nullable";
+    public static final String FIELD_NAME_PRECISION = "precision";
+    public static final String FIELD_NAME_SCALE = "scale";
+    public static final String FIELD_NAME_FIELDS = "fields";
+    public static final String FIELD_NAME_STRUCT_KIND = "structKind";
+    public static final String FIELD_NAME_TIMESTAMP_KIND = "timestampKind";
+    public static final String FIELD_NAME_ELEMENT = "element";
+    public static final String FIELD_NAME_KEY = "key";
+    public static final String FIELD_NAME_VALUE = "value";
+    public static final String FIELD_NAME_TYPE_INFO = "typeInfo";
+    public static final String FIELD_NAME_RAW_TYPE = "rawType";
+    public static final String FIELD_NAME_STRUCTURED_TYPE = "structuredType";
+
+    public RelDataTypeJsonSerializer() {
+        super(RelDataType.class);
+    }
+
+    @Override
+    public void serialize(
+            RelDataType relDataType,
+            JsonGenerator jsonGenerator,
+            SerializerProvider serializerProvider)
+            throws IOException {
+        jsonGenerator.writeStartObject();
+        serialize(relDataType, jsonGenerator);
+        jsonGenerator.writeEndObject();
+    }
+
+    private void serialize(RelDataType relDataType, JsonGenerator gen) throws IOException {
+        if (relDataType instanceof TimeIndicatorRelDataType) {

Review comment:
       can we reuse the Serde of LogicalType so that we don't need to have two kinds of type in json? such as FlinkTypeFactory#toLogicalType, I think Logic Type may be eable to cover RelDataType we are interested in. 




----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 0656ccf0bc8833314a41d6fcf0f0227821f8f5af Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962) 
   * 0e30f3541608abedd18beece54297e6815d6ae3c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot commented on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r584518154



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/EnumTypes.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.functions.FunctionKind;
+import org.apache.flink.table.types.logical.TimestampKind;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.calcite.sql.fun.SqlTrimFunction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Registry of {@link Enum} classes that can be serialized to JSON.
+ *
+ * <p>Suppose you want to serialize the value {@link SqlTrimFunction.Flag#LEADING} to JSON. First,
+ * make sure that {@link SqlTrimFunction.Flag} is registered. The type will be serialized as
+ * "SYMBOL". The value will be serialized as the string "LEADING".
+ *
+ * <p>When we deserialize, we rely on the fact that the registered {@code enum} classes have
+ * distinct values. Therefore, knowing that {@code (type="SYMBOL", value="LEADING")} we can convert
+ * the string "LEADING" to the enum {@code Flag.LEADING}.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public abstract class EnumTypes {
+    private EnumTypes() {}
+
+    private static final Map<String, Enum<?>> ENUM_BY_NAME;

Review comment:
       yes. If we know the specific enum type, we could just serialize the enum value through the name. But if we do not know the enum type (e.g. the literal with SYMBOL type), the class name should also be serialized if we do not use the above approach.




----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r584538940



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/JsonSerdeUtil.java
##########
@@ -44,15 +44,17 @@ public static boolean hasJsonCreatorAnnotation(Class<?> clazz) {
 
     /** Create an {@link ObjectMapper} which DeserializationContext wraps a {@link SerdeContext}. */
     public static ObjectMapper createObjectMapper(SerdeContext serdeCtx) {
+        FlinkDeserializationContext ctx =
+                new FlinkDeserializationContext(
+                        new DefaultDeserializationContext.Impl(BeanDeserializerFactory.instance),
+                        serdeCtx);
         ObjectMapper mapper =
                 new ObjectMapper(
                         null, // JsonFactory
                         null, // DefaultSerializerProvider
-                        new FlinkDeserializationContext(
-                                new DefaultDeserializationContext.Impl(
-                                        BeanDeserializerFactory.instance),
-                                serdeCtx));
+                        ctx);
         mapper.configure(MapperFeature.USE_GETTERS_AS_SETTERS, false);
+        ctx.setObjectMapper(mapper);

Review comment:
       Because we use the mapper to deserialize the `RelDataType`. There are two approach to avoid the cyclic dependency:
   1. we use `JsonParser` as streaming mode the deserialize the json. but it's very complex to support it, because the json structure is different for different RexNode.
   2. we create an ObjectMapper instance when it needed, and the corresponding serializers/deserializers are also needed to register, and it's a heavy operation to create an ObjectMapper instance.  




----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 531cf986cd749ee5465b768121f2ffa996f20e28 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773871449


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit d87084638f2714de24bfc578c88f852eda0613ee (Fri Feb 19 07:33:04 UTC 2021)
   
   **Warnings:**
    * **1 pom.xml files were touched**: Check for build and licensing issues.
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998",
       "triggerID" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 0e30f3541608abedd18beece54297e6815d6ae3c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r584522069



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/EnumTypes.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.functions.FunctionKind;
+import org.apache.flink.table.types.logical.TimestampKind;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.calcite.sql.fun.SqlTrimFunction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Registry of {@link Enum} classes that can be serialized to JSON.
+ *
+ * <p>Suppose you want to serialize the value {@link SqlTrimFunction.Flag#LEADING} to JSON. First,
+ * make sure that {@link SqlTrimFunction.Flag} is registered. The type will be serialized as
+ * "SYMBOL". The value will be serialized as the string "LEADING".
+ *
+ * <p>When we deserialize, we rely on the fact that the registered {@code enum} classes have
+ * distinct values. Therefore, knowing that {@code (type="SYMBOL", value="LEADING")} we can convert
+ * the string "LEADING" to the enum {@code Flag.LEADING}.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public abstract class EnumTypes {
+    private EnumTypes() {}
+
+    private static final Map<String, Enum<?>> ENUM_BY_NAME;

Review comment:
       the shortcoming of the above approach is the registered enums' names must be unique.  Currently, the registered enums' name are unique, but to avoid corner case in the future, I remove this class and serialize the class name to json.




----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998",
       "triggerID" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "bbe20063990703285bdfa7c37958151641534426",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14040",
       "triggerID" : "bbe20063990703285bdfa7c37958151641534426",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 0e30f3541608abedd18beece54297e6815d6ae3c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998) 
   * bbe20063990703285bdfa7c37958151641534426 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14040) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r584548717



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/RelDataTypeJsonSerializer.java
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.planner.plan.schema.GenericRelDataType;
+import org.apache.flink.table.planner.plan.schema.RawRelDataType;
+import org.apache.flink.table.planner.plan.schema.StructuredRelDataType;
+import org.apache.flink.table.planner.plan.schema.TimeIndicatorRelDataType;
+import org.apache.flink.table.types.logical.TimestampKind;
+import org.apache.flink.table.types.logical.TypeInformationRawType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+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 org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.sql.type.ArraySqlType;
+import org.apache.calcite.sql.type.MapSqlType;
+import org.apache.calcite.sql.type.MultisetSqlType;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import java.io.IOException;
+
+/**
+ * JSON serializer for {@link RelDataType}. refer to {@link RelDataTypeJsonDeserializer} for
+ * deserializer.
+ */
+public class RelDataTypeJsonSerializer extends StdSerializer<RelDataType> {
+    private static final long serialVersionUID = 1L;
+
+    public static final String FIELD_NAME_TYPE_NAME = "typeName";
+    public static final String FIELD_NAME_FILED_NAME = "fieldName";
+    public static final String FIELD_NAME_NULLABLE = "nullable";
+    public static final String FIELD_NAME_PRECISION = "precision";
+    public static final String FIELD_NAME_SCALE = "scale";
+    public static final String FIELD_NAME_FIELDS = "fields";
+    public static final String FIELD_NAME_STRUCT_KIND = "structKind";
+    public static final String FIELD_NAME_TIMESTAMP_KIND = "timestampKind";
+    public static final String FIELD_NAME_ELEMENT = "element";
+    public static final String FIELD_NAME_KEY = "key";
+    public static final String FIELD_NAME_VALUE = "value";
+    public static final String FIELD_NAME_TYPE_INFO = "typeInfo";
+    public static final String FIELD_NAME_RAW_TYPE = "rawType";
+    public static final String FIELD_NAME_STRUCTURED_TYPE = "structuredType";
+
+    public RelDataTypeJsonSerializer() {
+        super(RelDataType.class);
+    }
+
+    @Override
+    public void serialize(
+            RelDataType relDataType,
+            JsonGenerator jsonGenerator,
+            SerializerProvider serializerProvider)
+            throws IOException {
+        jsonGenerator.writeStartObject();
+        serialize(relDataType, jsonGenerator);
+        jsonGenerator.writeEndObject();
+    }
+
+    private void serialize(RelDataType relDataType, JsonGenerator gen) throws IOException {
+        if (relDataType instanceof TimeIndicatorRelDataType) {

Review comment:
       Some RelDataTypes are not support, such as `ANY`, `TIME_WITH_LOCAL_TIME_ZONE`, `SYMBOL`, `REAL`, `DISTINCT`




----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * d87084638f2714de24bfc578c88f852eda0613ee Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 531cf986cd749ee5465b768121f2ffa996f20e28 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 531cf986cd749ee5465b768121f2ffa996f20e28 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987) 
   * d87084638f2714de24bfc578c88f852eda0613ee Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 0656ccf0bc8833314a41d6fcf0f0227821f8f5af Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998",
       "triggerID" : "0e30f3541608abedd18beece54297e6815d6ae3c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * 0656ccf0bc8833314a41d6fcf0f0227821f8f5af Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962) 
   * 0e30f3541608abedd18beece54297e6815d6ae3c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13998) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7eed4a448147c00eb56b70e588eaa770a473996a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12987",
       "triggerID" : "531cf986cd749ee5465b768121f2ffa996f20e28",
       "triggerType" : "PUSH"
     }, {
       "hash" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054",
       "triggerID" : "d87084638f2714de24bfc578c88f852eda0613ee",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962",
       "triggerID" : "0656ccf0bc8833314a41d6fcf0f0227821f8f5af",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7eed4a448147c00eb56b70e588eaa770a473996a UNKNOWN
   * d87084638f2714de24bfc578c88f852eda0613ee Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13054) 
   * 0656ccf0bc8833314a41d6fcf0f0227821f8f5af Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13962) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot edited a comment on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773880848






----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot commented on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773871449


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 7eed4a448147c00eb56b70e588eaa770a473996a (Fri Feb 05 08:13:32 UTC 2021)
   
   **Warnings:**
    * **1 pom.xml files were touched**: Check for build and licensing issues.
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-21245).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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.

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



[GitHub] [flink] flinkbot commented on pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14878:
URL: https://github.com/apache/flink/pull/14878#issuecomment-773871449






----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r586155957



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/RelDataTypeJsonSerializer.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.planner.plan.schema.GenericRelDataType;
+import org.apache.flink.table.planner.plan.schema.RawRelDataType;
+import org.apache.flink.table.planner.plan.schema.StructuredRelDataType;
+import org.apache.flink.table.planner.plan.schema.TimeIndicatorRelDataType;
+import org.apache.flink.table.types.logical.TimestampKind;
+import org.apache.flink.table.types.logical.TypeInformationRawType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+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 org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.sql.type.ArraySqlType;
+import org.apache.calcite.sql.type.MapSqlType;
+import org.apache.calcite.sql.type.MultisetSqlType;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import java.io.IOException;
+
+/**
+ * JSON serializer for {@link RelDataType}. refer to {@link RelDataTypeJsonDeserializer} for
+ * deserializer.
+ */
+public class RelDataTypeJsonSerializer extends StdSerializer<RelDataType> {
+    private static final long serialVersionUID = 1L;
+
+    public static final String FIELD_NAME_TYPE_NAME = "typeName";
+    public static final String FIELD_NAME_FILED_NAME = "fieldName";
+    public static final String FIELD_NAME_NULLABLE = "nullable";
+    public static final String FIELD_NAME_PRECISION = "precision";
+    public static final String FIELD_NAME_SCALE = "scale";
+    public static final String FIELD_NAME_FIELDS = "fields";
+    public static final String FIELD_NAME_STRUCT_KIND = "structKind";
+    public static final String FIELD_NAME_TIMESTAMP_KIND = "timestampKind";
+    public static final String FIELD_NAME_ELEMENT = "element";
+    public static final String FIELD_NAME_KEY = "key";
+    public static final String FIELD_NAME_VALUE = "value";
+    public static final String FIELD_NAME_TYPE_INFO = "typeInfo";
+    public static final String FIELD_NAME_RAW_TYPE = "rawType";
+    public static final String FIELD_NAME_STRUCTURED_TYPE = "structuredType";
+
+    public RelDataTypeJsonSerializer() {
+        super(RelDataType.class);
+    }
+
+    @Override
+    public void serialize(
+            RelDataType relDataType,
+            JsonGenerator jsonGenerator,
+            SerializerProvider serializerProvider)
+            throws IOException {
+        jsonGenerator.writeStartObject();
+        serialize(relDataType, jsonGenerator);
+        jsonGenerator.writeEndObject();
+    }
+
+    private void serialize(RelDataType relDataType, JsonGenerator gen) throws IOException {
+        if (relDataType instanceof TimeIndicatorRelDataType) {
+            TimeIndicatorRelDataType timeIndicatorType = (TimeIndicatorRelDataType) relDataType;
+            gen.writeStringField(
+                    FIELD_NAME_TIMESTAMP_KIND,
+                    timeIndicatorType.isEventTime()
+                            ? TimestampKind.ROWTIME.name()
+                            : TimestampKind.PROCTIME.name());
+            gen.writeBooleanField(FIELD_NAME_NULLABLE, relDataType.isNullable());
+        } else if (relDataType instanceof StructuredRelDataType) {
+            StructuredRelDataType structuredType = (StructuredRelDataType) relDataType;
+            gen.writeObjectField(FIELD_NAME_STRUCTURED_TYPE, structuredType.getStructuredType());
+        } else if (relDataType.isStruct()) {
+            gen.writeStringField(FIELD_NAME_STRUCT_KIND, relDataType.getStructKind().name());
+            gen.writeBooleanField(FIELD_NAME_NULLABLE, relDataType.isNullable());
+
+            gen.writeFieldName(FIELD_NAME_FIELDS);
+            gen.writeStartArray();
+            for (RelDataTypeField field : relDataType.getFieldList()) {
+                gen.writeStartObject();
+                serialize(field.getType(), gen);
+                gen.writeStringField(FIELD_NAME_FILED_NAME, field.getName());
+                gen.writeEndObject();
+            }
+            gen.writeEndArray();
+        } else {
+            final SqlTypeName typeName = relDataType.getSqlTypeName();
+            gen.writeStringField(FIELD_NAME_TYPE_NAME, typeName.name());
+            gen.writeBooleanField(FIELD_NAME_NULLABLE, relDataType.isNullable());
+            if (relDataType.getSqlTypeName().allowsPrec()) {
+                gen.writeNumberField(FIELD_NAME_PRECISION, relDataType.getPrecision());
+            }
+            if (relDataType.getSqlTypeName().allowsScale()) {
+                gen.writeNumberField(FIELD_NAME_SCALE, relDataType.getScale());
+            }
+            if ((typeName == SqlTypeName.ARRAY)) {
+                ArraySqlType arraySqlType = (ArraySqlType) relDataType;
+                gen.writeFieldName(FIELD_NAME_ELEMENT);
+                gen.writeStartObject();
+                serialize(arraySqlType.getComponentType(), gen);
+                gen.writeEndObject();
+            } else if (typeName == SqlTypeName.MULTISET) {
+                assert relDataType instanceof MultisetSqlType;
+                MultisetSqlType multisetSqlType = (MultisetSqlType) relDataType;
+                gen.writeFieldName(FIELD_NAME_ELEMENT);
+                gen.writeStartObject();
+                serialize(multisetSqlType.getComponentType(), gen);
+                gen.writeEndObject();
+            } else if (typeName == SqlTypeName.MAP) {
+                assert relDataType instanceof MapSqlType;
+                MapSqlType mapSqlType = (MapSqlType) relDataType;
+
+                gen.writeFieldName(FIELD_NAME_KEY);
+                gen.writeStartObject();
+                serialize(mapSqlType.getKeyType(), gen);
+                gen.writeEndObject();
+
+                gen.writeFieldName(FIELD_NAME_VALUE);
+                gen.writeStartObject();
+                serialize(mapSqlType.getValueType(), gen);
+                gen.writeEndObject();
+            } else if (relDataType instanceof GenericRelDataType) {
+                assert typeName == SqlTypeName.ANY;
+                TypeInformationRawType<?> rawType =
+                        ((GenericRelDataType) relDataType).genericType();
+                gen.writeFieldName(FIELD_NAME_RAW_TYPE);
+                gen.writeStartObject();
+                gen.writeBooleanField(FIELD_NAME_NULLABLE, rawType.isNullable());
+                gen.writeStringField(
+                        FIELD_NAME_TYPE_INFO,
+                        EncodingUtils.encodeObjectToString(rawType.getTypeInformation()));
+                gen.writeEndObject();
+            } else if (relDataType instanceof RawRelDataType) {

Review comment:
       no, the else branch is line105-line113, I can improve this part and make it more readable.




----------------------------------------------------------------
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.

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



[GitHub] [flink] wenlong88 commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
wenlong88 commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r586102431



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/RelDataTypeJsonSerializer.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.planner.plan.schema.GenericRelDataType;
+import org.apache.flink.table.planner.plan.schema.RawRelDataType;
+import org.apache.flink.table.planner.plan.schema.StructuredRelDataType;
+import org.apache.flink.table.planner.plan.schema.TimeIndicatorRelDataType;
+import org.apache.flink.table.types.logical.TimestampKind;
+import org.apache.flink.table.types.logical.TypeInformationRawType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+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 org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.sql.type.ArraySqlType;
+import org.apache.calcite.sql.type.MapSqlType;
+import org.apache.calcite.sql.type.MultisetSqlType;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import java.io.IOException;
+
+/**
+ * JSON serializer for {@link RelDataType}. refer to {@link RelDataTypeJsonDeserializer} for
+ * deserializer.
+ */
+public class RelDataTypeJsonSerializer extends StdSerializer<RelDataType> {
+    private static final long serialVersionUID = 1L;
+
+    public static final String FIELD_NAME_TYPE_NAME = "typeName";
+    public static final String FIELD_NAME_FILED_NAME = "fieldName";
+    public static final String FIELD_NAME_NULLABLE = "nullable";
+    public static final String FIELD_NAME_PRECISION = "precision";
+    public static final String FIELD_NAME_SCALE = "scale";
+    public static final String FIELD_NAME_FIELDS = "fields";
+    public static final String FIELD_NAME_STRUCT_KIND = "structKind";
+    public static final String FIELD_NAME_TIMESTAMP_KIND = "timestampKind";
+    public static final String FIELD_NAME_ELEMENT = "element";
+    public static final String FIELD_NAME_KEY = "key";
+    public static final String FIELD_NAME_VALUE = "value";
+    public static final String FIELD_NAME_TYPE_INFO = "typeInfo";
+    public static final String FIELD_NAME_RAW_TYPE = "rawType";
+    public static final String FIELD_NAME_STRUCTURED_TYPE = "structuredType";
+
+    public RelDataTypeJsonSerializer() {
+        super(RelDataType.class);
+    }
+
+    @Override
+    public void serialize(
+            RelDataType relDataType,
+            JsonGenerator jsonGenerator,
+            SerializerProvider serializerProvider)
+            throws IOException {
+        jsonGenerator.writeStartObject();
+        serialize(relDataType, jsonGenerator);
+        jsonGenerator.writeEndObject();
+    }
+
+    private void serialize(RelDataType relDataType, JsonGenerator gen) throws IOException {
+        if (relDataType instanceof TimeIndicatorRelDataType) {
+            TimeIndicatorRelDataType timeIndicatorType = (TimeIndicatorRelDataType) relDataType;
+            gen.writeStringField(
+                    FIELD_NAME_TIMESTAMP_KIND,
+                    timeIndicatorType.isEventTime()
+                            ? TimestampKind.ROWTIME.name()
+                            : TimestampKind.PROCTIME.name());
+            gen.writeBooleanField(FIELD_NAME_NULLABLE, relDataType.isNullable());
+        } else if (relDataType instanceof StructuredRelDataType) {
+            StructuredRelDataType structuredType = (StructuredRelDataType) relDataType;
+            gen.writeObjectField(FIELD_NAME_STRUCTURED_TYPE, structuredType.getStructuredType());
+        } else if (relDataType.isStruct()) {
+            gen.writeStringField(FIELD_NAME_STRUCT_KIND, relDataType.getStructKind().name());
+            gen.writeBooleanField(FIELD_NAME_NULLABLE, relDataType.isNullable());
+
+            gen.writeFieldName(FIELD_NAME_FIELDS);
+            gen.writeStartArray();
+            for (RelDataTypeField field : relDataType.getFieldList()) {
+                gen.writeStartObject();
+                serialize(field.getType(), gen);
+                gen.writeStringField(FIELD_NAME_FILED_NAME, field.getName());
+                gen.writeEndObject();
+            }
+            gen.writeEndArray();
+        } else {
+            final SqlTypeName typeName = relDataType.getSqlTypeName();
+            gen.writeStringField(FIELD_NAME_TYPE_NAME, typeName.name());
+            gen.writeBooleanField(FIELD_NAME_NULLABLE, relDataType.isNullable());
+            if (relDataType.getSqlTypeName().allowsPrec()) {
+                gen.writeNumberField(FIELD_NAME_PRECISION, relDataType.getPrecision());
+            }
+            if (relDataType.getSqlTypeName().allowsScale()) {
+                gen.writeNumberField(FIELD_NAME_SCALE, relDataType.getScale());
+            }
+            if ((typeName == SqlTypeName.ARRAY)) {
+                ArraySqlType arraySqlType = (ArraySqlType) relDataType;
+                gen.writeFieldName(FIELD_NAME_ELEMENT);
+                gen.writeStartObject();
+                serialize(arraySqlType.getComponentType(), gen);
+                gen.writeEndObject();
+            } else if (typeName == SqlTypeName.MULTISET) {
+                assert relDataType instanceof MultisetSqlType;
+                MultisetSqlType multisetSqlType = (MultisetSqlType) relDataType;
+                gen.writeFieldName(FIELD_NAME_ELEMENT);
+                gen.writeStartObject();
+                serialize(multisetSqlType.getComponentType(), gen);
+                gen.writeEndObject();
+            } else if (typeName == SqlTypeName.MAP) {
+                assert relDataType instanceof MapSqlType;
+                MapSqlType mapSqlType = (MapSqlType) relDataType;
+
+                gen.writeFieldName(FIELD_NAME_KEY);
+                gen.writeStartObject();
+                serialize(mapSqlType.getKeyType(), gen);
+                gen.writeEndObject();
+
+                gen.writeFieldName(FIELD_NAME_VALUE);
+                gen.writeStartObject();
+                serialize(mapSqlType.getValueType(), gen);
+                gen.writeEndObject();
+            } else if (relDataType instanceof GenericRelDataType) {
+                assert typeName == SqlTypeName.ANY;
+                TypeInformationRawType<?> rawType =
+                        ((GenericRelDataType) relDataType).genericType();
+                gen.writeFieldName(FIELD_NAME_RAW_TYPE);
+                gen.writeStartObject();
+                gen.writeBooleanField(FIELD_NAME_NULLABLE, rawType.isNullable());
+                gen.writeStringField(
+                        FIELD_NAME_TYPE_INFO,
+                        EncodingUtils.encodeObjectToString(rawType.getTypeInformation()));
+                gen.writeEndObject();
+            } else if (relDataType instanceof RawRelDataType) {

Review comment:
       need a else branch to catch types we do not support to serialize?




----------------------------------------------------------------
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.

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



[GitHub] [flink] godfreyhe commented on a change in pull request #14878: [FLINK-21245][table-planner-blink] Support StreamExecCalc json serialization/deserialization

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #14878:
URL: https://github.com/apache/flink/pull/14878#discussion_r584518154



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/EnumTypes.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.functions.FunctionKind;
+import org.apache.flink.table.types.logical.TimestampKind;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.calcite.sql.fun.SqlTrimFunction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Registry of {@link Enum} classes that can be serialized to JSON.
+ *
+ * <p>Suppose you want to serialize the value {@link SqlTrimFunction.Flag#LEADING} to JSON. First,
+ * make sure that {@link SqlTrimFunction.Flag} is registered. The type will be serialized as
+ * "SYMBOL". The value will be serialized as the string "LEADING".
+ *
+ * <p>When we deserialize, we rely on the fact that the registered {@code enum} classes have
+ * distinct values. Therefore, knowing that {@code (type="SYMBOL", value="LEADING")} we can convert
+ * the string "LEADING" to the enum {@code Flag.LEADING}.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public abstract class EnumTypes {
+    private EnumTypes() {}
+
+    private static final Map<String, Enum<?>> ENUM_BY_NAME;

Review comment:
       yes. If we know the specific enum type, we could just serialize the enum value through the name. But if we do not know the enum type (e.g. the literal with SYMBOL type), we can't the enum value just through the name , the class name should also be serialized.




----------------------------------------------------------------
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.

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