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

SQL: Fix the inconsistent behaviour of ISO_WEEK_YEAR() (#68758) #68921

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

palesz
Copy link
Contributor

@palesz palesz commented Feb 11, 2021

The SELECT ISO_WEEK_OF_YEAR(a) AS x FROM test WHERE x=4 query returned
with x=3 results because the ISO_WEEK_YEAR(a) in the WHERE clause
that turns into a script query and the ISO_WEEK_YEAR(a) in the projections
that turns into a post-processing on top of the Query DSL results execute
different code to calculate the result.

This change unifies the different code paths and results in a single method
being responsible for the actual calculation.

Note: this change impacts the way how all the DateTimeFunctions that
do the field extraction from a date get translated into a script query.

Fixes part of #67872

(cherry-picked from bde0e41 )

The `SELECT ISO_WEEK_OF_YEAR(a) AS x FROM test WHERE x=4` query returned
with `x=3` results because the `ISO_WEEK_YEAR(a)` in the WHERE clause
that turns into a script query and the `ISO_WEEK_YEAR(a)` in the projections
that turns into a post-processing on top of the Query DSL results execute
different code to calculate the result.

This change unifies the different code paths and results in a single method
being responsible for the actual calculation.

Note: this change impacts the way how all the `DateTimeFunction`s that
do the field extraction from a date get translated into a script query.

Fixes part of elastic#67872
@palesz palesz added :Analytics/SQL SQL querying Team:QL (Deprecated) Meta label for query languages team labels Feb 11, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@palesz palesz merged commit b926d39 into elastic:7.x Feb 11, 2021
@palesz palesz deleted the iso_week_of_year-fix-7.x branch February 11, 2021 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying backport >bug Team:QL (Deprecated) Meta label for query languages team v7.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants