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: implicit CASTing between DATEs and DATETIMEs #49379

Closed
astefan opened this issue Nov 20, 2019 · 2 comments · Fixed by #52137
Closed

SQL: implicit CASTing between DATEs and DATETIMEs #49379

astefan opened this issue Nov 20, 2019 · 2 comments · Fixed by #52137
Assignees

Comments

@astefan
Copy link
Contributor

astefan commented Nov 20, 2019

We have a hard CASTing rule for DATEs and DATETIMEs, ie CAST(CAST(date AS STRING) AS DATE) will fail with SqlIllegalArgumentException[cannot cast [2004-06-04T00:00:00.000Z] to [date]: Text '2004-06-04T00:00:00.000Z' could not be parsed, unparsed text found at index 10] because a date and a time is not actually a date.
Should we loosen this hard rule for DATEs and DATETIMEs? Should we do implicit CASTing?

@elasticmachine
Copy link
Collaborator

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

@matriv matriv self-assigned this Feb 10, 2020
matriv added a commit to matriv/elasticsearch that referenced this issue Feb 10, 2020
Make the parsing of date more lenient
 - as an escaped literal: `{d '2020-02-10[[T| ]10:20[:30][.123456789][tz]]'}`
 - cast a string to a date: `CAST(2020-02-10[[T| ]10:20[:30][.123456789][tz]]' AS DATE)`

Closes: elastic#49379
matriv added a commit that referenced this issue Feb 10, 2020
Make the parsing of date more lenient

- as an escaped literal: `{d '2020-02-10[[T| ]10:20[:30][.123456789][tz]]'}`
- cast a string to a date: `CAST(2020-02-10[[T| ]10:20[:30][.123456789][tz]]' AS DATE)`

Closes: #49379
matriv added a commit that referenced this issue Feb 10, 2020
Make the parsing of date more lenient

- as an escaped literal: `{d '2020-02-10[[T| ]10:20[:30][.123456789][tz]]'}`
- cast a string to a date: `CAST(2020-02-10[[T| ]10:20[:30][.123456789][tz]]' AS DATE)`

Closes: #49379
(cherry picked from commit 5863b27)
@matriv
Copy link
Contributor

matriv commented Feb 10, 2020

master : 5863b27
7.x : 6b60085

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

Successfully merging a pull request may close this issue.

3 participants