Giter Club home page Giter Club logo

Comments (5)

nrwiersma avatar nrwiersma commented on June 12, 2024

Proposal 1:

Sure, props can be included, but your proposed solution has an issue in that maps are not ordered and so the output of the JSON may not be constant (comparable as a string), which would not be great.

Proposal 2:

The way ocf.NewEncoder() handles the schema is a little confusing:

It is parsed as it needs a schema object to encode and to know the passed string is actually a schema. It is re-encoded to be sure there is nothing random in the initial string that could be a security issue.

.String() isn't the same as .MarshalJSON(), and I'm not sure what its purpose is. It seems the convention in this package is to look like JSON, but not completely.

.String() returns the canonical schema which is needed for schema resolution. While not specifically stated, it is the minimal form of schema needed for reading, which is why it was chosen.

I have no issue with using the JSON form as long as it is constant, but to not make this a breaking change, I think it should be configurable.

from avro.

jacobmarble avatar jacobmarble commented on June 12, 2024

Everything you said makes sense. Thank you for the link about "Parsing Canonical Form", it clarifies a lot. I understand why the JSON and canonical forms are not treated the same way.

your proposed solution has an issue in that maps are not ordered and so the output of the JSON may not be constant (comparable as a string), which would not be great.

If we continue using Parsing Canonical Form in ocf.NewEncoder(), then does deterministic JSON key ordering matter in the JSON form? If the difference is in unit tests, then I can adjust those.

The way ocf.NewEncoder() handles the schema is a little confusing:

It is parsed as it needs a schema object to encode and to know the passed string is actually a schema. It is re-encoded to be sure there is nothing random in the initial string that could be a security issue.

Makes sense.

.String() returns the canonical schema which is needed for schema resolution. While not specifically stated, it is the minimal form of schema needed for reading, which is why it was chosen.

This is interesting because the Apache Iceberg reference implementation (Java) generates Avro files that include doc attributes, which are explicitly named as to be stripped in Transforming into Parsing Canonical Form.

New Proposal 1

In JSON form, always emit all attributes, including properties, doc, aliases.

Do not worry about JSON field ordering in JSON form.

New Proposal 2

In Parsing Canonical Form, add properties to the output, and make the property output optional, defaulting to not including properties.

from avro.

nrwiersma avatar nrwiersma commented on June 12, 2024

In JSON form, always emit all attributes, including properties, doc, aliases.

This makes sense. I would still prefer this to be ordered.

In Parsing Canonical Form, add properties to the output

This is a no go. From the spec, this form cannot contain other fields other than those specified in [STRIP]. It also has implications on the schema fingerprint.

from avro.

jacobmarble avatar jacobmarble commented on June 12, 2024

I'll work on the JSON form proposal, with deterministic ordering.

from avro.

jacobmarble avatar jacobmarble commented on June 12, 2024

The merged PR is enough to satisfy my needs, as I've written code to write files without the ocf package. Thanks for your help, @nrwiersma

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.