Skip to content

Name and Namespace fields for Schema::Duration #378

Closed

Description

@jdarais

According to the avro spec, Duration is a fixed type, and fixed types are required to have a name.

Should Schema::Duration contain a FixedSchema like other logical types that can use fixed as the underlying type like Schema::Decimal and Schema::Uuid? It can almost do without, since the fixed type's size is required to be 12 for the duration logical type, but it seems we still need a place to store name and namespace, otherwise that information will be lost at parsing time.

I'm happy to submit a PR for this, just wanted to check in case there's a reason Duration doesn't contain a FixedSchema already.

Activity

  1. martin-g commented on Dec 29, 2025

    @martin-g
    Member

    I'm happy to submit a PR for this, just wanted to check in case there's a reason Duration doesn't contain a FixedSchema already.

    No reason!
    We just merged #339 with improvements to DecimalSchema and UuidSchema related to this. We should do the same for Schema::Duration too!

    We should also add support for all of them at

    pub fn is_named(self) -> bool {
    too.

  2. jdarais commented on Dec 29, 2025

    @jdarais
    ContributorAuthor

    Sounds good! I've been playing with some changes for this, so I'll get those together in a PR and include changes to is_named, too.

    As far as is_named is concerned, would you be opposed to deprecating (or simply removing) SchemaKind::is_named, and having is_named implemented directly on the Schema enum type instead? It looks like it would be difficult to implement SchemaKind::is_named correctly for logical types like Decimal, where the underlying type could be fixed (which is named) or bytes (which is not,) since underlying type information is not included in SchemaKind.

  3. martin-g commented on Dec 29, 2025

    @martin-g
    Member

    Sure!

  4. martin-g commented on Jan 8, 2026

    @martin-g
    Member

    This has been fixed with #382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions