Skip to content
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

[ES|QL] Convert string to datetime when the other size of an arithmetic operator is date_period or time_duration #108455

Conversation

fang-xing-esql
Copy link
Contributor

Resolves : #108432

eval x = 1 day + "2024-01-01" this will work after this change. Users don't need to call to_dt explicitly like this eval x = 1 day + to_dt("2024-01-01")

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 9, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @fang-xing-esql, I've created a changelog YAML for you.

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Thanks @fang-xing-esql , looks good!

I'd increase test coverage a bit, though; maybe we could also add an analyzer/verifier test that confirms that arbitrary functions producing a (foldable) string can't be used, so that e.g. mv_concat("2024", "-04", "-01") + 1 day is invalid.

docs/changelog/108455.yaml Show resolved Hide resolved
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/kibana-esql (ES|QL-ui)

@fang-xing-esql
Copy link
Contributor Author

Thanks @fang-xing-esql , looks good!

I'd increase test coverage a bit, though; maybe we could also add an analyzer/verifier test that confirms that arbitrary functions producing a (foldable) string can't be used, so that e.g. mv_concat("2024", "-04", "-01") + 1 day is invalid.

Thanks for reviewing @alex-spies ! More tests are added as suggested.

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Thanks @fang-xing-esql, looking good!

Tiny suggestion for one more test, but this is already good to go as-is.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM

@fang-xing-esql
Copy link
Contributor Author

@costin @astefan @bpintea Could you help take another look at this? Thank you!

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

Lgtm.
I'd add two more tests (on top of all suggested ones): temporal ± string ± temporal and the other way around, string ± temporal ± string

@fang-xing-esql
Copy link
Contributor Author

Thanks for reviewing @costin @bpintea @alex-spies ! Just need to clean up CI.

@fang-xing-esql fang-xing-esql merged commit fa930cb into elastic:main Jun 4, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >enhancement ES|QL-ui Impacts ES|QL UI Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ES|QL] implicit datetime casting for binary operator args
5 participants