Skip to content

Commit

Permalink
clarify comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lovromazgon committed Jul 9, 2024
1 parent 3e7bd0d commit 67366f4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions schema/avro/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ func newUnionResolver(schema avro.Schema) unionResolver {
}
}

// AfterUnmarshal traverses the value using the schema and finds all values that
// have the Avro type Union. Those values are unmarshaled into a map with a
// single key that contains the name of the type
// (e.g. map[string]any{"string":"foo"}). This function takes that map and
// extracts the actual value from it (e.g. "foo").
// AfterUnmarshal traverses the input value 'val' using the schema and finds all
// fields that are of the Avro Union type. In the input 'val', these Union type
// fields are represented as maps with a single key that contains the name of
// the type (e.g. map[string]any{"string":"foo"}). This function processes those
// maps and extracts the actual value from them (e.g. "foo"), replacing the map
// representation with the actual value.
func (r unionResolver) AfterUnmarshal(val any) error {
if len(r.mapUnionPaths) == 0 &&
len(r.arrayUnionPaths) == 0 &&
Expand Down

0 comments on commit 67366f4

Please sign in to comment.