-
Notifications
You must be signed in to change notification settings - Fork 190
[BUG] Queries with date literals fail if date format does not includeepoch_millis #1847
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
What is the bug?
Timestamp literals are always converted to epoch_millis in OpenSearch DSL. This results in OpenSearch exception if the field does not support epoch_millis
How can one reproduce the bug?
Create an index with this mapping:
PUT /date-test
{
"mappings": {
"properties": {
"dateField": {
"type": "date",
"format": "strict_date_optional_time"
}
}
}
}
Add some data:
POST /date-test/_doc
{
"dateField": "2000-03-04"
}
POST /date-test/_doc
{
"dateField": "1999-01-02"
}
Execute SQL query:
POST /_plugins/sql
{
"query": "select * from date-test where dateField = date \"2002-03-04\""
}
Results in OpenSearch error:
{
"error": {
"details": "Shard[0]: [date-test/Yd43agSsSlqDvbN9XM13tw] QueryShardException[failed to create query: failed to parse date field [1015200000000] with format [strict_date_optional_time]: [failed to parse date field [1015200000000] with format [strict_date_optional_time]]]; nested: OpenSearchParseException[failed to parse date field [1015200000000] with format [strict_date_optional_time]: [failed to parse date field [1015200000000] with format [strict_date_optional_time]]]; nested: IllegalArgumentException[failed to parse date field [1015200000000] with format [strict_date_optional_time]]; nested: DateTimeParseException[Text '1015200000000' could not be parsed at index 0];\n\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
"reason": "Error occurred in OpenSearch engine: all shards failed",
"type": "SearchPhaseExecutionException"
},
"status": 400
}What is the expected behavior?
Query work to return one row.
Additional context
The query executes successfully if format for dateField includes epoch_millis.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working