Unwanted type literal added to data in textual
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
I have looked at the https://github.com/linkedin/goavro/issues/106 but I am not using any unions. My schema is as follows;
{
"type": "record",
"name": "Event",
"namespace": "com.xyz.event",
"fields": [
{
"name": "eventId",
"type": "string",
"doc": "Event ID"
},
{
"name": "eventSize",
"type": "int",
"doc": "Number of events within the event"
},
{
"name": "emittedTime",
"type": "long",
"doc": "Time when event was published"
},
{
"name": "context",
"type": [
"null",
{
"type": "map",
"values": "string"
}
],
"doc": "context information",
"default": null
},
{
"name" : "companyTable",
"type" : [ "null", "string" ],
"doc" : "event table prefix",
"default" : null
},
{
"name": "entityName",
"type": [
"null",
"string"
],
"doc": "Name of entity which triggered this event",
"default": null
},
{
"name": "entityId",
"type": [
"null",
"string"
],
"doc": "Identifier of entity which triggered this event",
"default": null
}
]
}
Code to decode is as follows;
codec, _ := goavro.NewCodec(schema)
native, _, _ := codec.NativeFromBinary(dataBytes)
textualbyte, err := codec.TextualFromNative(nil, native)
fmt.Println(Textual : string(textualbyte))
Above code produces following output;
{
"context": {
"map": {}
},
"eventSize": 2,
"emittedTime": 1560440525396,
"companyTable": null,
"entityName": {
"string": "FBNK.EB.CONTRACT.BALANCES"
},
"eventId": "96a485bd-7d95-443d-b604-ceb7c095be30",
"entityId": {
"string": "186079759760587"
}
}
How can I get rid of `string` under `entityId` and `entityName`. Why type is present in textual and is there any way I can get rid of it? where `eventSize` and `emittedTime` has correct values
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 the supplied schema and the NewCodec, NativeFromBinary, and TextualFromNative calls to reproduce the output for entityId and entityName. Trace how nullable union values are converted to textual form, then verify the result against the expected JSON while preserving correct handling of the other fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100