Comments (6)
You have added a nullable union, so you need an extra pointer to deal with the union.
from avro.
@nrwiersma could you give me an example, please?
from avro.
should I use a map?
func TestEncoder_FixedRat_Positive(t *testing.T) {
schema := `["null", {"type":"fixed", "name": "test", "size": 6,"logicalType":"decimal","precision":4,"scale":2}]`
buf := bytes.NewBuffer([]byte{})
enc, err := avro.NewEncoder(schema, buf)
require.NoError(t, err)
m := map[string]any{
"test": big.NewRat(1734, 5),
}
err = enc.Encode(m)
require.NoError(t, err)
assert.Equal(t, []byte{0x02, 0x00, 0x00, 0x00, 0x00, 0x87, 0x78}, buf.Bytes())
}
from avro.
I wonder why https://github.com/hamba/avro/blob/main/encoder_union_test.go#L427 -- this works for bytes, but doesn't work for fixed.
from avro.
You need to encode the pointer to the value, effectively a **big.Rat
.
val := big.NewRat(1734, 5)
err = enc.Encode(&val)
from avro.
Thank you @nrwiersma!
from avro.
Related Issues (20)
- [BUG] array schema cannot be correctly parsed HOT 4
- Local timestamp logical types HOT 1
- Add support for Zstandard compression
- Enum schema evolution for missing value in reader schema but with default HOT 3
- Question about max byte slice HOT 6
- Performance degradation in v2.19.0 HOT 4
- Wrong decoding of nested map HOT 1
- Infinite loop parsing recursive array type HOT 1
- "unknown union type long" error HOT 2
- Support nested array of record HOT 3
- Problem with empty slices vs nil. HOT 8
- Decode Array - Panic: Allocation size out of range Error HOT 1
- I struggle to have more than one "registered" type in the same field of a schema HOT 9
- Reasoning behind swallowing EOF errors? HOT 2
- Decoding of map[string]any behavior changed HOT 3
- [avrogen] tags - having omitEmpty in the json generated object HOT 8
- [avrogen] Avro int32s are mapped to Go ints HOT 2
- Serialize schemas feature HOT 3
- SchemaCompatibility.Compatible has one differ from apache/avro java implementation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avro.