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

Support Alternate Datetime Formats #268

Merged
merged 81 commits into from
May 29, 2023

Conversation

GumpacG
Copy link

@GumpacG GumpacG commented May 25, 2023

Description

Supports using date/time/timestamp formats obtained from OpenSearch. Contains some changes from OpenSearchDataType rework (8b2f65d). Resolves some issues previously seen on the forum (please see Issues Resolved section below).

Formats that require only dates will return type of date. For example, the format "basic_date" will have type date in the result. Formats that require only times will return type of time. For example, the format "basic_time" will have type time in the result. Formats that can have either date or time will return type of timestamp. For example, the format "basic_date||basic_time" will have type timestamp in the result. This is also the case when using aggregation like AVG.

Out of scope

Custom formats in the index mapping will be supported in a follow-up issue

TODO: Follow up with support for user-defined formats

Based on PoC (Here: https://github.com/Bit-Quill/opensearch-project-sql/pull/169/files).

Note: With these changes, issues may be introduced where data is read differently if a user's mapping defines a format. This is because the plugin previously used a hardcoded formatter to parse the data, while with these changes it will use the formatter defined in the mapping.

Supported formats include named formats listed in: opensearch/src/main/java/org/opensearch/sql/opensearch/data/type/OpenSearchDateType.java or https://opensearch.org/docs/latest/field-types/supported-field-types/date/

Issues Resolved

opensearch-project#794
https://forum.opensearch.org/t/sql-select-fails-on-date-fields-format-epoch-second/11521

Check List

  • New functionality includes testing.
    • 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
  • 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.

acarbonetto and others added 30 commits March 29, 2023 16:06
…Search types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
… With Datetime Types

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 2c16a554573015fcd752721353b2713858caad1a)
@acarbonetto
Copy link

Do we need to update any doctest?

GumpacG added 3 commits May 25, 2023 13:53
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
…rage

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
acarbonetto and others added 3 commits May 29, 2023 08:06
Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
docs/user/general/datatypes.rst Outdated Show resolved Hide resolved
switch (mappingType) {
public static OpenSearchDataType of(MappingType mappingType, Map<String, Object> innerMap) {
OpenSearchDataType res = instances.getOrDefault(mappingType.toString(),
new OpenSearchDataType(mappingType)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not null here? I think instances should contain all default instances since the very beginning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 58a8f19


private static final OpenSearchDateType instance = new OpenSearchDateType();

private static final String FORMAT_DELIMITER = "\\|\\|";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

Suggested change
private static final String FORMAT_DELIMITER = "\\|\\|";
private static final String FORMAT_DELIMITER_REGEX = "\\|\\|";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPD it is never used - remove?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 58a8f19

Comment on lines 132 to 134
super(MappingType.Date);
this.formatString = "";
this.exprCoreType = exprCoreType;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call one constructor from another one:

Suggested change
super(MappingType.Date);
this.formatString = "";
this.exprCoreType = exprCoreType;
this();
this.exprCoreType = exprCoreType;

And the same below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 58a8f19

(c, dt) -> ExprBooleanValue.of(c.booleanValue()))
//Handles the creation of DATE, TIME & DATETIME
.put(OpenSearchDateType.of(TIME),
(c, dt) -> createOpenSearchDateType(c, dt))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
(c, dt) -> createOpenSearchDateType(c, dt))
this::createOpenSearchDateType

You can do the same with next 3 entries

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 58a8f19

Comment on lines 123 to 124
if (OpenSearchDateType.isDateTypeCompatible(group.type())) {
builder.put(group.getNameOrAlias(), OpenSearchDateType.of(group.type()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this logic into OpenSearchDataType.of, so it will check compatibility and return the right object.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 58a8f19

Comment on lines 117 to 118
if (OpenSearchDateType.isDateTypeCompatible(e.type())) {
return OpenSearchDateType.of(e.type());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same - move compatibility check into of method

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 58a8f19

GumpacG added 3 commits May 29, 2023 13:25
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
@GumpacG GumpacG merged commit e64bb49 into integ-support-datetime-formats May 29, 2023
GumpacG added a commit that referenced this pull request May 29, 2023
* Add OpenSearchDateType as a datatype for matching with Date/Time OpenSearch types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Added IT Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added Basic Implementation

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added A Comment

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added Support For Default OpenSearch Formats

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Code Cleanup

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Refactored 'parsetimestamp' Function

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Cleanup

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Removed Unnecessary Try-Catch Block

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Unit Tests

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed IT Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Text Type and Disabled JSON Format Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fix Mapping Type Reporting As Date Instead Of Timestamp In Schema

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Revert Breaking Test Changes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Returned ExprCoreTypes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed OpenSearch Type Names In Mapping

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed LegacyTypeName Function And Refactored Code To Fix Calculations With Datetime Types

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Changed Support For Passing Fields Into Text Type

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reverted Some Changes And Commented Out A Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Commented Out A Breaking Change

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Minor Refactoring Changes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reworked parseTimestamp Function To Format Return Based On Enum

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Returned ExprValue

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reverted Changes To Test Files

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reverted Some Changes To Enum And Reworked Code

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added Type Mapping To Allow Query To Be Parsed

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Some Unit Tests

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed TypeActionMap To Still Support ExprCoreTypes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Wrapped Some Function Returns in ExprValueFactory

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Integration Test Bug

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 2c16a554573015fcd752721353b2713858caad1a)

* Slight Refactoring And Code Cleanup

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit ebecec79c79d75e851a4a0914cf4abf5aa6d3efd)

* Removed Unneeded Class Member

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 14de39815ebeecd36c4155099d875a45a7e008f6)

* Removed Unneccessary MappingType Parameters

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit e6a8bc3a6a3d7a11dacd03fc885871f3b055d2d2)

* Refactored Code To Fix Integration Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit c91f48d9763499940ecf302212fcd592aecb6018)

* Addressed JaCoCo Issues

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Checkstyle

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Changed gradle version and removed values iterator

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR Comments

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Update a test to match new indexResponse.aliases() type.

Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>

* Changed To Throw Exception When Encountering Parsing Failures

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Checkstyle

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Removed Unneeded Imports

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Re-enabled Some Tests

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Addressed PR Comments

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Changed test data

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Pulled out support for user-defined datetime formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Modified IT test data

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Added IT tests

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Removed support for just time and just date formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Removed unsupported formats from IT

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Removed unit tests for date only or time only formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR comments from previous PR

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR comment regarding unnecessary OpenSearchDateType instance in OpenSearchDataType

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Updates to include build-in date and time formats for OpenSearchDateTypes

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Add tests and fix checkstyle

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Fixed bugs regarding custom formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Add unit test to cover custom formats

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Addressed PR comments

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed checkstyle errors

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Modified integration test

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed Date and time aggregation

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed failing integ tests

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Modified integ test based on date format changes

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Added default formatters for date and time. Added unit tests for coverage

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Some minor review comments

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Addressed PR comments

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed checktsyle and jacoco

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Changed link in rst file

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Changed link in rst file

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR comments

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

---------

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
GumpacG added a commit that referenced this pull request May 30, 2023
* Add OpenSearchDateType as a datatype for matching with Date/Time OpenSearch types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Added IT Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added Basic Implementation

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added A Comment

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added Support For Default OpenSearch Formats

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Code Cleanup

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Refactored 'parsetimestamp' Function

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Cleanup

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Removed Unnecessary Try-Catch Block

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Unit Tests

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed IT Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Text Type and Disabled JSON Format Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fix Mapping Type Reporting As Date Instead Of Timestamp In Schema

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Revert Breaking Test Changes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Returned ExprCoreTypes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed OpenSearch Type Names In Mapping

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed LegacyTypeName Function And Refactored Code To Fix Calculations With Datetime Types

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Changed Support For Passing Fields Into Text Type

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reverted Some Changes And Commented Out A Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Commented Out A Breaking Change

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Minor Refactoring Changes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reworked parseTimestamp Function To Format Return Based On Enum

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Returned ExprValue

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reverted Changes To Test Files

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Reverted Some Changes To Enum And Reworked Code

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Added Type Mapping To Allow Query To Be Parsed

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Some Unit Tests

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed TypeActionMap To Still Support ExprCoreTypes

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Wrapped Some Function Returns in ExprValueFactory

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Integration Test Bug

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 2c16a554573015fcd752721353b2713858caad1a)

* Slight Refactoring And Code Cleanup

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit ebecec79c79d75e851a4a0914cf4abf5aa6d3efd)

* Removed Unneeded Class Member

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 14de39815ebeecd36c4155099d875a45a7e008f6)

* Removed Unneccessary MappingType Parameters

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit e6a8bc3a6a3d7a11dacd03fc885871f3b055d2d2)

* Refactored Code To Fix Integration Test

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit c91f48d9763499940ecf302212fcd592aecb6018)

* Addressed JaCoCo Issues

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Checkstyle

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Changed gradle version and removed values iterator

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR Comments

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Update a test to match new indexResponse.aliases() type.

Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>

* Changed To Throw Exception When Encountering Parsing Failures

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Checkstyle

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Removed Unneeded Imports

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Re-enabled Some Tests

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Addressed PR Comments

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Changed test data

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Pulled out support for user-defined datetime formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Modified IT test data

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Added IT tests

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Removed support for just time and just date formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Removed unsupported formats from IT

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Removed unit tests for date only or time only formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR comments from previous PR

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR comment regarding unnecessary OpenSearchDateType instance in OpenSearchDataType

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Updates to include build-in date and time formats for OpenSearchDateTypes

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Add tests and fix checkstyle

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Fixed bugs regarding custom formats

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Add unit test to cover custom formats

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Addressed PR comments

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed checkstyle errors

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Modified integration test

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed Date and time aggregation

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed failing integ tests

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Modified integ test based on date format changes

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Added default formatters for date and time. Added unit tests for coverage

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Some minor review comments

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

* Addressed PR comments

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Fixed checktsyle and jacoco

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Changed link in rst file

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Changed link in rst file

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

* Addressed PR comments

Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>

---------

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
Yury-Fridlyand pushed a commit that referenced this pull request May 30, 2023
* Support Alternate Datetime Formats (#268)

* Add OpenSearchDateType as a datatype for matching with Date/Time OpenSearch types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

---------

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
MitchellGale pushed a commit that referenced this pull request Jun 12, 2023
* Support Alternate Datetime Formats (#268)

* Add OpenSearchDateType as a datatype for matching with Date/Time OpenSearch types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

---------

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
MitchellGale pushed a commit that referenced this pull request Jun 12, 2023
* Support Alternate Datetime Formats (#268)

* Add OpenSearchDateType as a datatype for matching with Date/Time OpenSearch types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

---------

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
MitchellGale pushed a commit that referenced this pull request Jun 21, 2023
…rch-project#1682)

* Support Alternate Datetime Formats (#268)

* Add OpenSearchDateType as a datatype for matching with Date/Time OpenSearch types

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>

---------

Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
(cherry picked from commit 986db39)

Co-authored-by: Guian Gumpac <guian.gumpac@improving.com>
andy-k-improving pushed a commit that referenced this pull request Nov 16, 2024
Signed-off-by: Heemin Kim <heemin@amazon.com>
andy-k-improving pushed a commit that referenced this pull request Nov 16, 2024
* Implement creation of ip2geo feature (#257)

* Update gradle version to 7.6 (#265)

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>

* Implement creation of ip2geo feature

* Implementation of ip2geo datasource creation
* Implementation of ip2geo processor creation

Signed-off-by: Heemin Kim <heemin@amazon.com>
---------

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Signed-off-by: Heemin Kim <heemin@amazon.com>
Co-authored-by: Vijayan Balasubramanian <balasvij@amazon.com>

* Added unit tests with some refactoring of codes (#271)

* Add Unit tests
* Set cache true for search query
* Remove in memory cache implementation (Two way door decision)
 * Relying on search cache without custom cache
* Renamed datasource state from FAILED to CREATE_FAILED
* Renamed class name from *Helper to *Facade
* Changed updateIntervalInDays to updateInterval
* Changed value type of default update_interval from TimeValue to Long
* Read setting value from cluster settings directly

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Sync from main (#280)

* Update gradle version to 7.6 (#265)

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>

* Exclude lombok generated code from jacoco coverage report (#268)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Make jacoco report to be generated faster in local (#267)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Update dependency org.json:json to v20230227 (#273)

Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com>

* Baseline owners and maintainers (#275)

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>

---------

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Signed-off-by: Heemin Kim <heemin@amazon.com>
Co-authored-by: Vijayan Balasubramanian <balasvij@amazon.com>
Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com>

* Add datasource name validation (#281)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Refactoring of code (#282)

1. Change variable name from datasourceName to name
2. Change variable name from id to name
3. Added helper methods in test code

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Change field name from md5 to sha256 (#285)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Implement get datasource api (#279)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Update index option (#284)

1. Make geodata index as hidden
2. Make geodata index as read only allow delete after creation is done
3. Refresh datasource index immediately after update

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Make some fields in manifest file as mandatory (#289)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Create datasource index explicitly (#283)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add wrapper class of job scheduler lock service (#290)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Remove all unused client attributes (#293)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Update copyright header (#298)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Run system index handling code with stashed thread context (#297)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Reduce lock duration and renew the lock during update (#299)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Implements delete datasource API (#291)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Set User-Agent in http request (#300)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Implement datasource update API (#292)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Refactoring test code (#302)

Make buildGeoJSONFeatureProcessorConfig method to be more general

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add ip2geo processor integ test for failure case (#303)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Bug fix and refactoring of code (#305)

1. Bugfix: Ingest metadata can be null if there is no processor created
2. Refactoring: Moved private method to another class for better testing support
3. Refactoring: Set some private static final variable as public so that unit test can use it
4. Refactoring: Changed string value to static variable

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add integration test for Ip2GeoProcessor (#306)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add ConcurrentModificationException (#308)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add integration test for UpdateDatasource API (#307)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Bug fix on lock management and few performance improvements (#310)

* Release lock before response back to caller for update/delete API
* Release lock in background task for creation API
* Change index settings to improve indexing performance

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Change index setting from read_only_allow_delete to write (#311)

read_only_allow_delete does not block write to an index.
The disk-based shard allocator may add and remove this block automatically.
Therefore, use index.blocks.write instead.

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Fix bug in get datasource API and improve memory usage (#313)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Change package for Strings.hasText (#314) (#317)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Remove jitter and move index setting from DatasourceFacade to DatasourceExtension (#319)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Do not index blank value and do not enrich null property (#320)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Move index setting keys to constants (#321)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Return null index name for expired data (#322)

Return null index name for expired data so that it can be deleted
by clean up process. Clean up process exclude current index from deleting.
Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add new fields in datasource (#325)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Delete index once it is expired (#326)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add restoring event listener (#328)

In the listener, we trigger a geoip data update

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Reverse forcemerge and refresh order (#331)

Otherwise, opensearch does not clear old segment files

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Removed parameter and settings (#332)

* Removed first_only parameter
* Removed max_concurrency and batch_size setting

first_only parameter was added as current geoip processor has it.
However, the parameter have no benefit for ip2geo processor as we don't do a sequantial search for array data but use multi search.

max_concurrency and batch_size setting is removed as these are only reveal internal implementation and could be a future blocker to improve performance later.

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add a field in datasource for current index name (#333)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Delete GeoIP data indices after restoring complete (#334)

We don't want to use restored GeoIP data indices. Therefore we
delete the indices once restoring process complete.

When GeoIP metadata index is restored, we create a new GeoIP data index instead.

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Use bool query for array form of IPs (#335)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Run update/delete request in a new thread (#337)

This is not to block transport thread

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Remove IP2Geo processor validation (#336)

Cannot query index to get data to validate IP2Geo processor.
Will add validation when we decide to store some of data in cluster state metadata.

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Acquire lock sychronously (#339)

By acquiring lock asychronously, the remaining part of the code
is being run by transport thread which does not allow blocking code.
We want only single update happen in a node using single thread. However,
it cannot be acheived if I acquire lock asynchronously and pass the listener.

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Added a cache to store datasource metadata (#338)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Changed class name and package (#341)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Refactoring of code (#342)

1. Changed class name from Ip2GeoCache to Ip2GeoCachedDao
2. Moved the Ip2GeoCachedDao from cache to dao package

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add geo data cache (#340)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Add cache layer to reduce GeoIp data retrieval latency (opensearch-project#343)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Use _primary in query preference and few changes (opensearch-project#347)

1. Use _primary preference to get datasource metadata so that it can read the latest data. RefreshPolicy.IMMEDIATE won't refresh replica shards immediately according to #346
2. Update datasource metadata index mapping
3. Move batch size from static value to setting

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Wait until GeoIP data to be replicated to all data nodes (opensearch-project#348)

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Update packages according to a change in OpenSearch core (opensearch-project#354)

* Update packages according to a change in OpenSearch core

Signed-off-by: Heemin Kim <heemin@amazon.com>

* Update packages according to a change in OpenSearch core (opensearch-project#353)

Signed-off-by: Heemin Kim <heemin@amazon.com>

---------

Signed-off-by: Heemin Kim <heemin@amazon.com>

---------

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Signed-off-by: Heemin Kim <heemin@amazon.com>
Co-authored-by: Vijayan Balasubramanian <balasvij@amazon.com>
Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants