Question about default value's representation for fixed, decimal, etc
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
In record.go, the default value given in the schema is validated using binaryFromNative.
https://github.com/linkedin/goavro/blob/master/record.go#L77
Should the validation of the default value be made against the textual representation instead of the native representation?
Checking the default value against the native representation has some issues. For example, several types have some native go representation, (eg. decimal's native representation is *big.Rat), you cannot set its default value in the json avro schema.
Interestingly, fixed has its native representation as []byte, but its default value can be given (as the spec allows) as a string. It seems that some workaround in fixed's binaryFromNative was done here
https://github.com/linkedin/goavro/blob/master/fixed.go#L41-L42
to accept a string as also native representation.
My questions are:
1. Do we accept several native representation?
2. If the answer to 1 is yes, should we use this rule to also add a string representation handling in their binaryFromNative to accept those default values represented as string?
3. If the answer to 1 is no, should we use NativeFromTextual to validate the default value and have a single native representation?
Or choose there some other consistent rules. In any case, I think the current code is inconsistent in the default value handling.
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
Read record.go around the default-value validation and compare binaryFromNative with NativeFromTextual. Then inspect fixed.go's string handling and the linked Avro schema behavior for decimal and fixed defaults. Done means agreeing on one consistent default-value representation rule and identifying the corresponding validation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100