Skip to content

Support for Avro logical types#1233

Open
e11it wants to merge 7 commits intoAiven-Open:mainfrom
e11it:rest-avro-logical-types
Open

Support for Avro logical types#1233
e11it wants to merge 7 commits intoAiven-Open:mainfrom
e11it:rest-avro-logical-types

Conversation

@e11it
Copy link
Copy Markdown

@e11it e11it commented Mar 14, 2026

Support for Avro logical types:

  • timestamp-millis
  • timestamp-micros
  • date
  • time-millis
  • time-micros
  • decimal

New config flag:
rest_avro_extended_json_parser: bool = False # default: Confluent-compatible behaviour

When True:

  • logical types(timestamp, date, time) also accept ISO 8601 strings in addition to integers
  • allow to pass Decimal as int or string ("1234.34")

@e11it e11it requested a review from a team as a code owner March 14, 2026 23:08
else:
data = flatten_unions(schema.schema, value)
flattened = flatten_unions(schema.schema, value)
data = convert_logical_types(schema.schema, flattened)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this declaration ?

return value


def convert_logical_types(schema: avro.schema.Schema, value: Any) -> Any:
Copy link
Copy Markdown
Contributor

@muralibasani muralibasani Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a docstring explaining its purpose, which types it handles, etc


# Timestamps
if logical_type == "timestamp-millis" and isinstance(value, int):
epoch = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - these constants are recreated on every call.

@muralibasani muralibasani force-pushed the rest-avro-logical-types branch from 0ca3b53 to 0bd4434 Compare March 30, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants