Skip to content

SQL: adds format parameter to range queries for constant date comparisons #45326

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

Merged
merged 7 commits into from
Aug 13, 2019

Conversation

astefan
Copy link
Contributor

@astefan astefan commented Aug 8, 2019

Whenever a date field is used in a <, >, <=, >= comparison, a range query is built. This includes any output from CURRENT_*/NOW/TODAY functions. This PR adds the format parameter to these range queries and sets the value of the date constant as String.

Also, it changes the = and != operators to use a range query as well, to have the proper format for the literal used in the equality/non-equality condition.

Fixes #45139.

@astefan astefan added >bug :Analytics/SQL SQL querying labels Aug 8, 2019
@astefan astefan requested a review from costin August 8, 2019 10:58
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@astefan
Copy link
Contributor Author

astefan commented Aug 9, 2019

@elasticmachine run elasticsearch-ci/default-distro

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

client().performRequest(request);
}

private ZonedDateTime nowWithMillisResolution(String zoneId) {
Copy link
Member

Choose a reason for hiding this comment

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

Can't you use DateUtils.nowWithMillisResolution?

@astefan
Copy link
Contributor Author

astefan commented Aug 13, 2019

@elasticmachine run elasticsearch-ci/2

@astefan
Copy link
Contributor Author

astefan commented Aug 13, 2019

@elasticmachine run elasticsearch-ci/packaging-sample

@astefan astefan merged commit c1e81e9 into elastic:master Aug 13, 2019
@astefan astefan deleted the 45139__fix branch August 13, 2019 11:56
astefan added a commit to astefan/elasticsearch that referenced this pull request Aug 13, 2019
…sons (elastic#45326)

* Add format parameter to the range queries built for CURRENT_* functions
used in comparison conditions
* Use range queries for date fields equality/non-equality as well.

(cherry picked from commit c1e81e9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL: conditions involving date fields with custom format and SQL-generated dates fail
4 participants