sql icon indicating copy to clipboard operation
sql copied to clipboard

Add support for custom date formats and OpenSearch date formats for date fields as part of Lucene query

Open manasvinibs opened this issue 8 months ago • 0 comments

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 be OpenSearchDateType object instead of ExprCoretype enums passed as a param to the Lucene QueryBuilder.
  • Extract OpenSearchDateNamedFormatters and OpenSearchDateCustomFormatters from the OpenSearchDateType 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 the core module to use OpenSearch provided DateFormatter and DateFormatters 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.

manasvinibs avatar Jun 18 '24 22:06 manasvinibs