-
Notifications
You must be signed in to change notification settings - Fork 141
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
[BUG] SQL query doesn't honor date format in OpenSearch index mapping #794
Comments
Isn't a duplicate/related to #126? |
I added it to Issue 2. Issue 1 is slightly different. I think both has same root cause. |
Mapping: {
"mappings" : {
"properties" : {
"key" : {
"type" : "keyword"
},
"val" : {
"type" : "date",
"format": "time_no_millis"
}
}
}
} Data { "index" : { "_id" : "1" } }
{"key": "null", "val": null}
{ "index" : { "_id" : "2" } }
{"key": "001: 00:00:00", "val": "08:00:00Z"}
{ "index" : { "_id" : "3" } }
{"key": "002: 00:00:01", "val": "08:00:01Z"}
{ "index" : { "_id" : "4" } }
{"key": "003: 01:00:00", "val": "09:00:00Z"} Exception stack:
|
@Yury-Fridlyand @MaxKsyunz Here are some examples with which users had problem previously: Index mapping:
Data:
Query:
|
@Yury-Fridlyand Are we planning to support this in 2.6.0 release once the PoC # 180 done? |
@dai-chen, yes |
I am having the same issue as the author after updating to 2.9. |
What is the bug?
It seems SQL query engine doesn't honor what's configured in OpenSearch index mapping for date field. This causes problems in different queries with datetime field involved. See examples below.
How can one reproduce the bug?
As documented,
"strict_date_optional_time||epoch_millis"
is the default format if not specified in index mapping. The issue happens when custom date format is configured as below. Note that this is mostly due to the gaps between engine v2 and the legacy (which may not have these issues at all).Issue 1: Datetime literal parsing problem
With
epoch_millis
format removed in mapping, the previous work query throws exception now. From the error message, it seems caused by epoch timestamp used in DSL translated rather than the onlystrict_date_optional_time
configured. Note that OpenSearch doesn't complain this in any syntax/semantic check (probably due to missing semantic check), but throw exception at execution time instead.Issue 2: Datetime value parsing problem
Related: #126, opendistro-for-elasticsearch/sql#1062
No matter what date format configured,
OpenSearchExprValueFactory
always uses the hardcoding formatter insql/opensearch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Line 86 in b0ef5e0
What is the expected behavior?
OpenSearch SQL/PPL should honor the date format in index mapping and parse date value from OpenSearch or date literals in query accordingly.
Currently only data type is returned and associated with field. One approach to improve this is reading datetime format from OpenSearch along with basic field type info. Code:
sql/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchIndex.java
Line 60 in b0ef5e0
What is your host/environment?
Do you have any screenshots?
N/A
Do you have any additional context?
Similar issues may apply to PPL as well due to single core engine shared across languages.
The text was updated successfully, but these errors were encountered: