[ 
https://issues.apache.org/jira/browse/BEAM-8406?focusedWorklogId=350047&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-350047
 ]

ASF GitHub Bot logged work on BEAM-8406:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Nov/19 21:30
            Start Date: 26/Nov/19 21:30
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on pull request #10217: [BEAM-8406] 
Add support for JSON format text tables
URL: https://github.com/apache/beam/pull/10217#discussion_r350989547
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/text/TextTableProvider.java
 ##########
 @@ -141,6 +156,51 @@ public LinesReadConverter() {}
     }
   }
 
+  /** Read-side converter for {@link TextJsonTable} with format {@code 
'json'}. */
+  @VisibleForTesting
+  static class JsonToRow extends PTransform<PCollection<String>, 
PCollection<Row>>
+      implements Serializable {
+
+    private ObjectMapper objectMapper;
+    private Schema schema;
+
+    @VisibleForTesting
+    public JsonToRow(ObjectMapper objectMapper, Schema schema) {
+      this.objectMapper = objectMapper;
+      this.schema = schema;
+    }
+
+    @Override
+    public PCollection<Row> expand(PCollection<String> input) {
+      return input
+          .apply(
+              ParDo.of(
+                  new DoFn<String, Row>() {
+                    @ProcessElement
+                    public void processElement(ProcessContext context) {
 
 Review comment:
   Will need a design or documentation in the case if there is a row that does 
not match the schema. If you check pubsub json support, it supports a dead 
letter queue that sends rows to that queue if those rows does not match with 
the schema. You might reuse the same design.
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 350047)
    Time Spent: 40m  (was: 0.5h)

> TextTable support JSON format
> -----------------------------
>
>                 Key: BEAM-8406
>                 URL: https://issues.apache.org/jira/browse/BEAM-8406
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Jing Chen
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Have a JSON table implementation similar to [1].
> [1]: 
> https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/text/TextTable.java



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to