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

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

                Author: ASF GitHub Bot
            Created on: 19/Feb/20 09:08
            Start Date: 19/Feb/20 09:08
    Worklog Time Spent: 10m 
      Work Description: alexvanboxel commented on pull request #10883: 
[BEAM-9331] Add better Row builders
URL: https://github.com/apache/beam/pull/10883#discussion_r381158593
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
 ##########
 @@ -55,8 +59,31 @@
  * {@link Row} is an immutable tuple-like schema to represent one element in a 
{@link PCollection}.
  * The fields are described with a {@link Schema}.
  *
- * <p>{@link Schema} contains the names for each field and the coder for the 
whole record,
- * {see @link Schema#getRowCoder()}.
+ * <p>{@link Schema} contains the names and types for each field.
+ *
+ * <p>There are several ways to build a new Row object. To build a row from 
scratch using a schema
+ * object, {@link Row#withSchema} can be used. Schema fields can be specified 
by name, and nested
+ * fields can be specified using the field selection syntax. For example:
+ *
+ * <pre>{@code
+ * Row row = Row.withSchema(schema)
+ *              .withFieldValue("userId", "user1)
+ *              .withFieldValue("location.city", "seattle")
+ *              .withFieldValue("location.state", "wa")
+ *              .build();
+ * }</pre>
+ *
+ * <p>The {@link Row#fromRow} builder can be used to base a row off of another 
row. The builder can
+ * be used to specify values for specific fields, and all the remaining values 
will be taken from
+ * the original row. For example, the following produces a row identical to 
the above row except for
+ * the location.city field.
+ *
+ * <pre>{@code
+ * Row modifiedRow =
+ *     Row.fromRow(row)
+ *        .withFieldValue("location.city", "tacoma")
 
 Review comment:
   Nope, I like the proposed `withFieldValue`.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 389360)
    Time Spent: 1.5h  (was: 1h 20m)

> The Row object needs better builders
> ------------------------------------
>
>                 Key: BEAM-9331
>                 URL: https://issues.apache.org/jira/browse/BEAM-9331
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Users should be able to build a Row object by specifying field names. Desired 
> syntax:
>  
> Row.withSchema(schema)
>    .withFieldName("field1", "value)
>   .withFieldName("field2.field3", value)
>   .build()
>  
> Users should also have a builder that allows taking an existing row and 
> changing specific fields.



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

Reply via email to