Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions website/www/site/content/en/documentation/programming-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4164,14 +4164,31 @@ as schema fields may have different requirements or restrictions from Go exporte

### 6.6. Using Schema Transforms {#using-schemas}

A schema on a `PCollection` enables a rich variety of relational transforms. The fact that each record is composed of
named fields allows for simple and readable aggregations that reference fields by name, similar to the aggregations in
a SQL expression.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this?


{{< paragraph class="language-go">}}
Beam does not yet support Schema transforms natively in Go. However, it will be implemented with the following behavior.
In Go, schemas are inferred from struct types. You can use schema-aware
<code>PCollection</code>s by defining structs and accessing their fields
directly in transforms. The following example demonstrates extracting
a nested field from a schema-aware collection.
{{< /paragraph >}}

{{< highlight go >}}
type ShippingAddress struct {
PostCode string `beam:"postCode"`
}
type Purchase struct {
ShippingAddress ShippingAddress `beam:"shippingAddress"`
}
purchases := beam.Create(s,
Purchase{
ShippingAddress: ShippingAddress{PostCode: "12345"},
},
)
postCodes := beam.ParDo(s, func(p Purchase) string {
return p.ShippingAddress.PostCode
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just shows how you can access fields of a Go object, it seems unrelated to schemas

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I've restored the original schema description .

}, purchases)
{{< /highlight >}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of dropping this into the top level section, we should follow the same pattern used by the other languages



#### 6.6.1. Field selection syntax

The advantage of schemas is that they allow referencing of element fields by name. Beam provides a selection syntax for
Expand Down