sql
sql copied to clipboard
Add support for custom date formats and OpenSearch date formats for date fields as part of Lucene query
Description
This change adds support for OpenSearch Date formats and custom date formats to be part of SQL Lucene queries. Without this change, we are supporting only list of selected formats which always gets formatted to ISO local string or epoch before submitting to opensearch dsl query.
- Refactors
ExprType
to beOpenSearchDateType
object instead ofExprCoretype
enums passed as a param to the Lucene QueryBuilder. - Extract
OpenSearchDateNamedFormatters
andOpenSearchDateCustomFormatters
from theOpenSearchDateType
object which is set during IndexMapping field parsing for a field type. - Format information is passed to the
ExprValue
implementation constructor to parse the date string using the field specific formatters. - Adds unit tests for all the different formats use cases.
- Adds
OpenSearch
package dependency to thecore
module to use OpenSearch providedDateFormatter
andDateFormatters
classes instead of java provided DateFormatter.
Issues Resolved
https://github.com/opensearch-project/sql/issues/2700
Check List
- [X] New functionality includes testing.
- [X] All tests pass, including unit test, integration test and doctest
- [ ] New functionality has been documented.
- [ ] New functionality has javadoc added
- [ ] New functionality has user manual doc added
- [X] Commits are signed per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.