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: multi-conditionals on date fields with NOW() don't use the format for range queries #48033

Closed
astefan opened this issue Oct 15, 2019 · 2 comments · Fixed by #48073
Closed
Assignees
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Oct 15, 2019

SELECT hire_date FROM test_emp WHERE hire_date >= NOW() - INTERVAL 200 YEARS AND hire_date < NOW() - INTERVAL 2 YEARS

will end up returning an error:

"root_cause": [
            {
                "type": "parse_exception",
                "reason": "failed to parse date field [1819-10-15T04:45:20.641Z] with format [yyyy-MM-dd' 'HH:mm:ss]: [failed to parse date field [1819-10-15T04:45:20.641Z] with format [yyyy-MM-dd' 'HH:mm:ss]]"
            }
        ]

The error above does also happen only when the date format of the hire_date field is a custom one (non-default).
The reason for the error seems to be the lack of format attribute (added following this PR) on the range ES query generated for this sql query, which should enforce the range query to one known format - the one of NOW(), CURRENT_DATE() functions.

@astefan astefan self-assigned this Oct 15, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/SQL)

@astefan
Copy link
Contributor Author

astefan commented Oct 25, 2019

master (8.0.0): 020939a
7.x (7.5.0): 3233b59
7.4 (7.4.1): 9d12541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants