Comments (9)
Hi,
String()
as noted in the docs returns the canonical form of the schema. Canonical forms are meant to determine what is considered the same schema from the PoV of the reader. As default
has not effect for a reader (it is only used by the writer to fill missing data) it is not included in the canonical form.
So this is very intentional and noted in the spec here (look at [STRIP]
).
Hope that answers your question.
from avro.
from avro.
From the spec:
Parsing Canonical Form is a transformation of a writer's schema that let's us define what it means for two schemas to be "the same" for the purpose of reading data written against the schema
So the canonical is definitely from the PoV of a reader.
The default values definitely play into the behavior of a reader schema as
they are required for the reader to know what to return when the datum
being read does not contain a field defined in the reader schema.
This is simply not true. The default is only applied by the writer. The encoded data will always have a value for a field, it is simply not possible for it not to as it would become impossible to decode. So the default is only applied by the writer and as no bearing and is useless to the reader.
from avro.
So I think I now understand the misunderstanding here. I think you are talking about composable schemas when a reader schema is composed with a writer schema to get a schema to read a datum. This library does not yet support this form. It is expected you will decode with the writer schema at this point.
This is something I have looked at in the past, but it is very complex. I hope to have the time at some point to take a crack at this.
At any rate, this form does not require default
to be in the canonical form, and this field property is specifically removed from the canonical form in the spec.
Hope this helps.
from avro.
from avro.
Yeah, in your case your want to generate a full schema rather than a canonical schema. In reality it would not be a massive addition to the lib if you would be interested in making the contribution. I think the "correct" approach would be to handle it as a json.Marshaler
, so you would json encode the schema. This would provide the best separation between canonical String()
or Stringer
and full.
Is this something you would be interested in?
from avro.
from avro.
No stress if you dont have time. I have some time coming up, so I might take a stab at it in a week or so.
from avro.
from avro.
Related Issues (20)
- AvroGen: generates duplicate structs due to a name resolution conflict HOT 7
- Schema with duplicate names should throw error
- Encoding to JSON does not reference reused types HOT 1
- Unmarshaling Interface Types in a Union HOT 6
- Reset the schema cache? HOT 4
- AVRO schema refs with Hamba avro HOT 8
- Support original name for structs
- Add protocol original schema string HOT 4
- Infinite loop parsing recursive schema HOT 1
- Encoding a struct with a sub-record field default value failed HOT 2
- avrogen: does not support logicalType: "uuid" in a union
- Support TextMarshaler/TextUnmarshaler for map keys HOT 2
- need an method generate schema from struct HOT 7
- Bug for tree typed schema HOT 2
- [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
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.