GithubHelp home page GithubHelp logo

Comments (9)

nrwiersma avatar nrwiersma commented on May 19, 2024

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.

mpetronic avatar mpetronic commented on May 19, 2024

from avro.

nrwiersma avatar nrwiersma commented on May 19, 2024

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.

nrwiersma avatar nrwiersma commented on May 19, 2024

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.

mpetronic avatar mpetronic commented on May 19, 2024

from avro.

nrwiersma avatar nrwiersma commented on May 19, 2024

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.

mpetronic avatar mpetronic commented on May 19, 2024

from avro.

nrwiersma avatar nrwiersma commented on May 19, 2024

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.

mpetronic avatar mpetronic commented on May 19, 2024

from avro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.