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]