feat: add timestamp_to_datetime_format_expr optional rule paramameter #978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
No breaking changes.
The goal of this PR is to provide a way to transform a timestamp returned by Elasticsearch before parsing it into a datetime.
This come from an issue we have when using a custom timestamp field that can contains nanoseconds. For now, the parsing of the returned timestamp raise a Value error, as there is 3 additional digit that can't be parse in python (datetime.datetime.strptime format doesn't support nanoseconds). And I found no workaround (other that changing the timestamp format in Elasticsearch of course).
It seems logic that as we can choose a way to modify a timestamp before sending it to Elastisearch, we could also do the same when retrieving one.
So this PR simply add a rule parameter called timestamp_to_datetime_format_expr that does the same thing as timestamp_format_expr in the _ts_to_dt_with_format function instead of _dt_to_ts_with_format.
I didn't want to use the same rule parameter to avoid any breaking changes, and corner case I could not anticipate.
Checklist
make test-docker
with my changes.Questions or Comments
Got some docker layer cache issues running make test-docker, will create another small PR to fix that.