Skip to content

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

Open
Aleksander Lech (aleksanderlech) wants to merge 1 commit into
confluentinc:masterfrom
aleksanderlech:bugfix/date-should-be-passed-as-epochmillis
Open

Convert org.apache.kafka.connect.data.Date to epoch millis before sending to Elasticsearch#842
Aleksander Lech (aleksanderlech) wants to merge 1 commit into
confluentinc:masterfrom
aleksanderlech:bugfix/date-should-be-passed-as-epochmillis

Conversation

@aleksanderlech

Copy link
Copy Markdown

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
@confluent-cla-assistant

confluent-cla-assistant Bot commented Feb 26, 2025

Copy link
Copy Markdown

🎉 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.

@aleksanderlech

Copy link
Copy Markdown
Author

Hello any chance of merging?

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