You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "FangYongs (via GitHub)" <gi...@apache.org> on 2023/02/28 03:53:51 UTC
[GitHub] [flink] FangYongs commented on a diff in pull request #13081: [FLINK-18590][json] Support json array explode to multi messages
FangYongs commented on code in PR #13081:
URL: https://github.com/apache/flink/pull/13081#discussion_r1119548371
##########
docs/content/docs/connectors/table/formats/json.md:
##########
@@ -241,6 +241,41 @@ The following table lists the type mapping from Flink type to JSON type.
</tbody>
</table>
+Features
+--------
+### Allow top-level JSON Arrays
+Usually, we assume the top-level of json string is a json object. Then the json object is converted to one SQL row.
+There are some cases that, the top-level of json string is a json array, and we want to explode the array to
+multiple records, each one of the array is a json object which is converted to one row. Flink JSON Format supports
+read such data implicitly.
+
+For example, for the following SQL DDL:
+<div class="codetabs" markdown="1">
+<div data-lang="SQL" markdown="1">
+{% highlight sql %}
+CREATE TABLE user_behavior (
+ col1 BIGINT,
+ col2 DOUBLE,
+ col3 VARCHAR,
+ col4 BOOLEAN
+) WITH (
+ 'format' = 'json',
+ ...
+)
+{% endhighlight %}
+</div>
+</div>
+
+Flink JSON Format will produce 2 rows `(123, "a")` and `(456, "b")` with both of following two json string.
+The top-level is JSON Array:
+{% highlight json %}
+[{"col1": 123, "col2": "a"}, {"col1": 456, "col2": "b"}]
+{% endhighlight %}
+The top-level is JSON Object:
+{% highlight json %}
+{"col1": 123, "col2": "a"}
+{"col1": 456, "col2": "b"}
Review Comment:
I cannot see the top-level JSON Object here, they are just two JSON Object here?
--
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