External State Join in YTsaurus Flow (Go)
An example of a pipeline that enriches events from a queue with data from a read-only external state. The reference table is attached through TSimpleExternalStateJoiner, and the Go computation looks a row up by the event key.
Structure
event_reader— a native queue source that publishes theeventstream.lookup_join(lookupJoin) — a Go transform computation grouped bykey. It reads/referencethroughexternal_state_joinersand publishes the enriched message to theenrichedstream.- A queue sink stores the messages from
enriched.
The joiner path in the spec may point to a Cypress link. This lets you switch the reference data to a new version of the table atomically, without restarting the pipeline.
main.go
The entry point registers the schemas of the input and output streams, adds the computation, and starts the pipeline.
lookup_join.go
The computation decodes the typed input message, reads the joined state row, and creates a typed output message.
Key patterns
flow.OpenJoinedExternalState(rt, referenceStateName, msg)opens the read-only state for the key of the current message.flow.ErrStateNotReadmeans that there is no joined row for the key; in this case the example publishes no result.ConvertTostays at the SDK boundary: the business logic works witheventMessage,referenceState, andenrichedMessagerather than with raw wire-protocol rows.- The joined external state isn’t changed from the computation: the
ConvertFrommethod isn’t used for it.
See also
Previous
Next