Support for default value for union of records
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
We have a schema where one of the attributes is a union of two record types:
```
{
"type": "record",
"name": "Thing",
"namespace": "universe.of.things",
"fields": [
{
"name": "layout",
"type": [
{
"type": "record",
"name": "AnotherThing",
"namespace": "another.universe.of.things",
"fields": [
{
"name": "text",
"type": "string",
"default": "someText"
}
]
},
{
"type": "record",
"name": "AnotherThing2",
"namespace": "another.universe.of.things",
"fields": [
{
"name": "text",
"type": "string",
"default": "someOtherText"
}
]
}
],
"default": {
"another.universe.of.things.AnotherThing": {
"text": "someDefaultText"
}
}
}
]
}
```
When putting it through `NewCodec` we get an error: `Record "universe.of.things.Thing" field "layout": default value ought to encode using field schema: cannot encode binary union: no member schema types support datum: allowed types: [another.universe.of.things.AnotherThing another.universe.of.things.AnotherThing2]; received: map[string]interface {}`
I created a PR #123 which works fine for us, and is what we're using for now.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with NewCodec and the supplied union-of-record schema, then compare the current behavior with PR #123, which the report says already works for this case. Done means the default value for the union of records is accepted without the reported encoding error and existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100