Skip to content

Convert org.apache.kafka.connect.data.Date to epoch millis before sending to Elasticsearch #842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aleksanderlech
Copy link

Problem

Lets consider the following kafka schema:

{
      "name": "dateOfBirth",
      "type": [ "null", {"type": "int", "logicalType": "date"}],
      "default": null
}

And the target index field:

  "dateOfBirth": {
      "type": "date"
    }

Currently the date type (org.apache.kafka.connect.data.Date) is being converted to int (epoch days) and ends up in Elasticsearch being interpreted as epoch millis turning it into some datetime long in the past.

Elasticsearch does not suport epoch days type for date fields.

Solution

Assuming the field is properly indexed as date we should pass some of default supported formats like epoch_millis.

Does this solution apply anywhere else?
  • yes
  • no
If yes, where?

Test Strategy

Testing done:
  • Unit tests
  • Integration tests
  • System tests
  • [x ] Manual tests

Release Plan

Bugfix, it might be have some incompatibles with existing user workarounds though.

…och days which is not supported by Elasticsearch
@aleksanderlech aleksanderlech requested a review from a team as a code owner February 26, 2025 07:27
@confluent-cla-assistant
Copy link

confluent-cla-assistant bot commented Feb 26, 2025

🎉 All Contributor License Agreements have been signed. Ready to merge.
✅ aleksanderlech
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

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.

1 participant