Skip to content

fix(codecs): Support avro date values#24774

Open
omwbennett wants to merge 12 commits intovectordotdev:masterfrom
omwbennett:support-avro-date-values
Open

fix(codecs): Support avro date values#24774
omwbennett wants to merge 12 commits intovectordotdev:masterfrom
omwbennett:support-avro-date-values

Conversation

@omwbennett
Copy link
Copy Markdown

Summary

Fixes #24773 by adding support for decoding Avro date values.

Vector configuration

sources:
  kafka_avro:
    type: kafka
    bootstrap_servers: "kafka:9092"
    group_id: "vector"
    topics:
      - test_topic
    decoding:
      codec: avro
      avro:
        schema: |
          {
            "type": "record",
            "name": "test",
            "fields": [
              {
                "name": "date_field",
                "type": { "type": "int", "logicalType": "date" }
              }
            ]
          }
        strip_schema_id_prefix: false

sinks:
  console_out:
    type: console
    inputs:
      - kafka_avro
    encoding:
      codec: json

How did you test this PR?

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Closes #24773

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

@omwbennett omwbennett requested a review from a team as a code owner February 26, 2026 16:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 26, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@omwbennett
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@omwbennett omwbennett force-pushed the support-avro-date-values branch from 1ecf525 to 40d0d6a Compare February 26, 2026 16:27
@omwbennett omwbennett force-pushed the support-avro-date-values branch from 40d0d6a to aa24899 Compare February 26, 2026 16:28
@omwbennett omwbennett requested a review from a team as a code owner March 3, 2026 14:59
@github-actions github-actions Bot added the domain: external docs Anything related to Vector's external, public documentation label Mar 3, 2026
@rtrieu rtrieu self-assigned this Mar 3, 2026
@omwbennett
Copy link
Copy Markdown
Author

Hey @vectordotdev/vector, appreciate if you could review this PR, thanks!

@pront
Copy link
Copy Markdown
Member

pront commented Apr 2, 2026

@codex review

Hi @omwbennett, thanks for contributing to Vector. I enabled the workflows and requested a first pass from codex.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 857b4b3903

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1 @@
{"name":"test","type":"record","fields":[{"name":"date_field","type":{"type":"int"}}]} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve logicalType in date fixture schema

roundtrip_avro_fixtures reads this .avsc as the schema, but the new fixture stores date_field as plain int ({"type":{"type":"int"}}) rather than an Avro date logical type. That means decoding this fixture produces AvroValue::Int, so the new AvroValue::Date branch added in try_from is never exercised by tests; regressions in real logicalType: "date" inputs could pass CI unnoticed. Please keep the fixture schema with logicalType: "date" on the field type object so the test validates the intended path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@omwbennett this seems like a valid comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This seems to be because the apache-avro dependency was updated to 0.20.0 which changed/fixed canonical_form() to remove logicalTypes, however the avro test fixtures were not re-generated until now.

I've updated the fixture generator to pass the schema as-is into the .avsc fixture file so we don't lose any parts of the schema.

This uncovered a bug in the Avro encoder where it's unable to encode a vrl Integer back to an Avro Date, so I've addressed this by making the encoder aware of the schema using a new method to_avro() in the encode path that maps different vrl values to Avro types based on the schema. I also went ahead and added support for a few other types as those looked straightforward.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb2cbd735b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lib/codecs/src/encoding/format/avro.rs Outdated
omwbennett and others added 2 commits April 23, 2026 09:59
check-spelling run (pull_request_target) for support-avro-date-values

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>
@github-actions github-actions Bot added the domain: ci Anything related to Vector's CI environment label Apr 23, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5336c62721

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lib/codecs/src/encoding/format/avro.rs Outdated
@pront
Copy link
Copy Markdown
Member

pront commented Apr 24, 2026

Hi @omwbennett, happy to review this once all codex comments are addressed (feel free to decline those with a justification if they do not make sense)

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

Labels

domain: ci Anything related to Vector's CI environment domain: external docs Anything related to Vector's external, public documentation work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avro decoder doesn't support Date values

3 participants