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

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

                Author: ASF GitHub Bot
            Created on: 01/Oct/21 14:28
            Start Date: 01/Oct/21 14:28
    Worklog Time Spent: 10m 
      Work Description: jrmccluskey commented on a change in pull request 
#15632:
URL: https://github.com/apache/beam/pull/15632#discussion_r720287476



##########
File path: website/www/site/content/en/documentation/programming-guide.md
##########
@@ -2666,6 +2666,11 @@ infer the correct schema based on the members of the 
class.
 In Python you can use the following set of classes to represent the purchase 
schema. Beam will automatically infer the correct schema based on the members 
of the class.
 {{< /paragraph >}}
 
+{{< paragraph class="language-go" >}}
+In Go, schema encoding used by default for struct types, with Exported fields 
becoming part of the schema.

Review comment:
       Is there a word missing here?

##########
File path: website/www/site/content/en/documentation/programming-guide.md
##########
@@ -3191,13 +3264,63 @@ output_pc = input_pc | beam.Map(lambda item: 
beam.Row(bank=str(item["bank"]),
                                                       
purchase_amount=float(item["purchase_amount"])))
 {{< /highlight >}}
 
+{{< paragraph class="language-go" >}}
+Beam currently only infers schemas for exported fields in Go structs.
+{{< /paragraph >}}
+
+{{< paragraph class="language-go" >}}
+**Structs**
+{{< /paragraph >}}
+
+{{< paragraph class="language-go" >}}
+Beam will automatically infer schemas for all Go structs used
+as PCollection elements, and default to encoding them using
+schema encoding.
+{{< /paragraph >}}
+
+{{< highlight go >}}
+type Transaction struct{
+  Bank string
+  PurchaseAmount float64
+
+  checksum []byte // ignored
+}
+{{< /highlight >}}
+
+{{< paragraph class="language-go" >}}
+Unexported fields are ignored, and cannot be automatically infered as part of 
the schema.
+Fields of type  func, channel, unsafe.Pointer, or uintptr will be ignored by 
inference.
+Fields of interface types are ignored, unless a schema provider
+is registered for them.
+{{< /paragraph >}}
+
+{{< paragraph class="language-go" >}}
+By default, schema field names will match the exported struct field names.
+In the above example, "Bank" and "PurchaseAmount" are the schema field names.
+A schema field name can be overridden with a struct tag for the field.
+{{< /paragraph >}}
+
+{{< highlight go >}}
+type Transaction struct{
+  Bank           string  `beam:"bank"`
+  PurchaseAmount float64 `beam:"purchase_amount"`
+}
+{{< /highlight >}}
+
+{{< paragraph class="language-go" >}}
+Overriding schema field names is useful for compatibility cross language 
transforms.

Review comment:
       Is it worth elaborating on this point a bit or linking to documentation 
that does? This line being stand-alone in its current context doesn't convey 
much information.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 658977)
    Time Spent: 9.5h  (was: 9h 20m)

> Complete Go SDK inclusion to Beam Programming Guide
> ---------------------------------------------------
>
>                 Key: BEAM-12513
>                 URL: https://issues.apache.org/jira/browse/BEAM-12513
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Robert Burke
>            Assignee: Robert Burke
>            Priority: P2
>          Time Spent: 9.5h
>  Remaining Estimate: 0h
>
> BPG Go Audit snapshot: 
> [https://docs.google.com/spreadsheets/d/1DrBFjxPBmMMmPfeFr6jr_JndxGOes8qDqKZ2Uxwvvds/edit?resourcekey=0-tVFwcLrQ2v2jpZkHk6QOpQ#gid=2072310090]
> Goal is to include Go SDK code for all missing snippets, and where code can't 
> yet exist, file and link a Jira instead.



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

Reply via email to