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 2022/07/25 15:36:01 UTC

[GitHub] [flink] zentol opened a new pull request, #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

zentol opened a new pull request, #20355:
URL: https://github.com/apache/flink/pull/20355

   Add a basic JSON (de)serialization scheme for reading/writing any jackson-supported type.
   
   Also deprecates the `JsonNodeDeserializationSchema` because it's now kinda redundant.


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

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

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


[GitHub] [flink] zentol commented on pull request #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

Posted by GitBox <gi...@apache.org>.
zentol commented on PR #20355:
URL: https://github.com/apache/flink/pull/20355#issuecomment-1195637892

   > It's very common for deserializers to include an implementation of getProducedType.
   
   We extend the `AbstractDeserializationSchema` which takes care of that based on the class/typeinfo passed to the constructor.


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

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

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


[GitHub] [flink] alpinegizmo commented on pull request #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

Posted by GitBox <gi...@apache.org>.
alpinegizmo commented on PR #20355:
URL: https://github.com/apache/flink/pull/20355#issuecomment-1194755608

   This seems like something so useful it should show up in the documentation somewhere.


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

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

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


[GitHub] [flink] zentol commented on pull request #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

Posted by GitBox <gi...@apache.org>.
zentol commented on PR #20355:
URL: https://github.com/apache/flink/pull/20355#issuecomment-1195415060

   @alpinegizmo I added some documentation.


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

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

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


[GitHub] [flink] flinkbot commented on pull request #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "8a19cd04cb3e0d98d14846877c28b0aaf7742133",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "8a19cd04cb3e0d98d14846877c28b0aaf7742133",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 8a19cd04cb3e0d98d14846877c28b0aaf7742133 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@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.

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

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


[GitHub] [flink] alpinegizmo commented on a diff in pull request #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

Posted by GitBox <gi...@apache.org>.
alpinegizmo commented on code in PR #20355:
URL: https://github.com/apache/flink/pull/20355#discussion_r930088762


##########
docs/content.zh/docs/connectors/datastream/formats/json.md:
##########
@@ -0,0 +1,77 @@
+---
+title:  "JSON"
+weight: 4
+type: docs
+---
+<!--
+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.
+-->
+
+# Json format
+
+To use the JSON format you need to add the Flink JSON dependency to your project:
+
+```xml
+<dependency>
+	<groupId>org.apache.flink</groupId>
+	<artifactId>flink-json</artifactId>
+	<version>{{< version >}}</version>
+	<scope>provided</scope>
+</dependency>
+```
+
+Flink supports reading/writing JSON records via the `JsonSerializationSchema/JsonDeserializationSchema`.
+These utilize the [Jackson](https://github.com/FasterXML/jackson) library, and support any type that is supported by Jackson, including, but not limited to, `POJO`s and `ObjectNode`.
+
+The `JsonDeserializationSchema` can be used with any connector that supports the `DeserializationSchema`.
+
+For example, this is how you use it with a `KafkaSource` to deserialize a `POJO`:
+
+```java
+JsonDeserializationSchema<SomePojo> jsonFormat = new JsonDeserializationSchema<>(SomePojo.class);
+KafkaSource<SomePojo> source =
+    KafkaSource.<SomePojo>builder()
+        .setValueOnlyDeserializer(jsonFormat)
+        ...
+```
+
+The `JsonSerializationSchema` can be used with any connector that supports the `SerializationSchema`.
+
+For example, this is how you use it with a `KafkaSink` to serialize a `POJO`:
+
+```java
+JsonSerializationSchema<SomePojo> jsonFormat = new JsonSerializationSchema<>();
+KafkaSink<SomePojo> source =
+    KafkaSink.<SomePojo>builder()
+        .setRecordSerializer(
+            new KafkaRecordSerializationSchemaBuilder<>()
+                .setValueSerializationSchema(jsonFormat)
+                ...
+```
+
+## Custom Mapper
+
+Both schemas have constructors that accept a `SerializableSupplier<ObjectMapper>`, acting a factory for object mappers.

Review Comment:
   ```suggestion
   Both schemas have constructors that accept a `SerializableSupplier<ObjectMapper>`, acting as a factory for object mappers.
   ```



##########
docs/content/docs/connectors/datastream/formats/json.md:
##########
@@ -0,0 +1,77 @@
+---
+title:  "JSON"
+weight: 4
+type: docs
+---
+<!--
+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.
+-->
+
+# Json format
+
+To use the JSON format you need to add the Flink JSON dependency to your project:
+
+```xml
+<dependency>
+	<groupId>org.apache.flink</groupId>
+	<artifactId>flink-json</artifactId>
+	<version>{{< version >}}</version>
+	<scope>provided</scope>
+</dependency>
+```
+
+Flink supports reading/writing JSON records via the `JsonSerializationSchema/JsonDeserializationSchema`.
+These utilize the [Jackson](https://github.com/FasterXML/jackson) library, and support any type that is supported by Jackson, including, but not limited to, `POJO`s and `ObjectNode`.
+
+The `JsonDeserializationSchema` can be used with any connector that supports the `DeserializationSchema`.
+
+For example, this is how you use it with a `KafkaSource` to deserialize a `POJO`:
+
+```java
+JsonDeserializationSchema<SomePojo> jsonFormat=new JsonDeserializationSchema<>(SomePojo.class);
+KafkaSource<SomePojo> source=
+    KafkaSource.<SomePojo>builder()
+        .setValueOnlyDeserializer(jsonFormat)
+        ...
+```
+
+The `JsonSerializationSchema` can be used with any connector that supports the `SerializationSchema`.
+
+For example, this is how you use it with a `KafkaSink` to serialize a `POJO`:
+
+```java
+JsonSerializationSchema<SomePojo> jsonFormat=new JsonSerializationSchema<>();
+KafkaSink<SomePojo> source  = 
+    KafkaSink.<SomePojo>builder()
+        .setRecordSerializer(
+            new KafkaRecordSerializationSchemaBuilder<>()
+                .setValueSerializationSchema(jsonFormat)
+                ...
+```
+
+## Custom Mapper
+
+Both schemas have constructors that accept a `SerializableSupplier<ObjectMapper>`, acting a factory for object mappers.
+With this factory you gain full control over the created mapper, and can enable/disable various Jackson features or register modules to extend the set of supported types or add additional functionality.

Review Comment:
   ```suggestion
   With this factory you gain full control over the created mapper, and you can enable/disable various Jackson features or register modules to extend the set of supported types or add additional functionality.
   ```



##########
docs/content.zh/docs/connectors/datastream/formats/json.md:
##########
@@ -0,0 +1,77 @@
+---
+title:  "JSON"
+weight: 4
+type: docs
+---
+<!--
+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.
+-->
+
+# Json format
+
+To use the JSON format you need to add the Flink JSON dependency to your project:
+
+```xml
+<dependency>
+	<groupId>org.apache.flink</groupId>
+	<artifactId>flink-json</artifactId>
+	<version>{{< version >}}</version>
+	<scope>provided</scope>
+</dependency>
+```
+
+Flink supports reading/writing JSON records via the `JsonSerializationSchema/JsonDeserializationSchema`.
+These utilize the [Jackson](https://github.com/FasterXML/jackson) library, and support any type that is supported by Jackson, including, but not limited to, `POJO`s and `ObjectNode`.
+
+The `JsonDeserializationSchema` can be used with any connector that supports the `DeserializationSchema`.
+
+For example, this is how you use it with a `KafkaSource` to deserialize a `POJO`:
+
+```java
+JsonDeserializationSchema<SomePojo> jsonFormat = new JsonDeserializationSchema<>(SomePojo.class);
+KafkaSource<SomePojo> source =
+    KafkaSource.<SomePojo>builder()
+        .setValueOnlyDeserializer(jsonFormat)
+        ...
+```
+
+The `JsonSerializationSchema` can be used with any connector that supports the `SerializationSchema`.
+
+For example, this is how you use it with a `KafkaSink` to serialize a `POJO`:
+
+```java
+JsonSerializationSchema<SomePojo> jsonFormat = new JsonSerializationSchema<>();
+KafkaSink<SomePojo> source =
+    KafkaSink.<SomePojo>builder()
+        .setRecordSerializer(
+            new KafkaRecordSerializationSchemaBuilder<>()
+                .setValueSerializationSchema(jsonFormat)
+                ...
+```
+
+## Custom Mapper
+
+Both schemas have constructors that accept a `SerializableSupplier<ObjectMapper>`, acting a factory for object mappers.
+With this factory you gain full control over the created mapper, and can enable/disable various Jackson features or register modules to extend the set of supported types or add additional functionality.

Review Comment:
   ```suggestion
   With this factory you gain full control over the created mapper, and you can enable/disable various Jackson features or register modules to extend the set of supported types or add additional functionality.
   ```



##########
docs/content/docs/connectors/datastream/formats/json.md:
##########
@@ -0,0 +1,77 @@
+---
+title:  "JSON"
+weight: 4
+type: docs
+---
+<!--
+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.
+-->
+
+# Json format
+
+To use the JSON format you need to add the Flink JSON dependency to your project:
+
+```xml
+<dependency>
+	<groupId>org.apache.flink</groupId>
+	<artifactId>flink-json</artifactId>
+	<version>{{< version >}}</version>
+	<scope>provided</scope>
+</dependency>
+```
+
+Flink supports reading/writing JSON records via the `JsonSerializationSchema/JsonDeserializationSchema`.
+These utilize the [Jackson](https://github.com/FasterXML/jackson) library, and support any type that is supported by Jackson, including, but not limited to, `POJO`s and `ObjectNode`.
+
+The `JsonDeserializationSchema` can be used with any connector that supports the `DeserializationSchema`.
+
+For example, this is how you use it with a `KafkaSource` to deserialize a `POJO`:
+
+```java
+JsonDeserializationSchema<SomePojo> jsonFormat=new JsonDeserializationSchema<>(SomePojo.class);
+KafkaSource<SomePojo> source=
+    KafkaSource.<SomePojo>builder()
+        .setValueOnlyDeserializer(jsonFormat)
+        ...
+```
+
+The `JsonSerializationSchema` can be used with any connector that supports the `SerializationSchema`.
+
+For example, this is how you use it with a `KafkaSink` to serialize a `POJO`:
+
+```java
+JsonSerializationSchema<SomePojo> jsonFormat=new JsonSerializationSchema<>();
+KafkaSink<SomePojo> source  = 
+    KafkaSink.<SomePojo>builder()
+        .setRecordSerializer(
+            new KafkaRecordSerializationSchemaBuilder<>()
+                .setValueSerializationSchema(jsonFormat)
+                ...
+```
+
+## Custom Mapper
+
+Both schemas have constructors that accept a `SerializableSupplier<ObjectMapper>`, acting a factory for object mappers.

Review Comment:
   ```suggestion
   Both schemas have constructors that accept a `SerializableSupplier<ObjectMapper>`, acting as a factory for object mappers.
   ```



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

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

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


[GitHub] [flink] zentol merged pull request #20355: [FLINK-28634][json] Add simple JsonSerDeSchema

Posted by GitBox <gi...@apache.org>.
zentol merged PR #20355:
URL: https://github.com/apache/flink/pull/20355


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

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

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