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
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
8b2f65d
Add OpenSearchDateType as a datatype for matching with Date/Time Open…
acarbonetto Mar 29, 2023
c5ad8e0
Added IT Test
GabeFernandez310 Mar 30, 2023
a64b93e
Added Basic Implementation
GabeFernandez310 Apr 4, 2023
cbf3c38
Added A Comment
GabeFernandez310 Apr 4, 2023
a780bbd
Added Support For Default OpenSearch Formats
GabeFernandez310 Apr 5, 2023
ffede70
Code Cleanup
GabeFernandez310 Apr 5, 2023
3708a6f
Refactored 'parsetimestamp' Function
GabeFernandez310 Apr 6, 2023
bc15e3a
Cleanup
GabeFernandez310 Apr 9, 2023
a5fac5c
Removed Unnecessary Try-Catch Block
GabeFernandez310 Apr 9, 2023
9c2a7c8
Fixed Unit Tests
GabeFernandez310 Apr 13, 2023
0f01283
Fixed IT Test
GabeFernandez310 Apr 13, 2023
5c63d7f
Fixed Text Type and Disabled JSON Format Test
GabeFernandez310 Apr 17, 2023
675aa02
Fix Mapping Type Reporting As Date Instead Of Timestamp In Schema
GabeFernandez310 Apr 18, 2023
09d420b
Revert Breaking Test Changes
GabeFernandez310 Apr 18, 2023
a519501
Fixed Returned ExprCoreTypes
GabeFernandez310 Apr 18, 2023
ed2bcbb
Fixed OpenSearch Type Names In Mapping
GabeFernandez310 Apr 18, 2023
ef90ad6
Fixed LegacyTypeName Function And Refactored Code To Fix Calculations…
GabeFernandez310 Apr 18, 2023
418dc98
Changed Support For Passing Fields Into Text Type
GabeFernandez310 Apr 18, 2023
0670812
Reverted Some Changes And Commented Out A Test
GabeFernandez310 Apr 18, 2023
5543fd8
Commented Out A Breaking Change
GabeFernandez310 Apr 19, 2023
9325d24
Minor Refactoring Changes
GabeFernandez310 Apr 19, 2023
89cb4ce
Reworked parseTimestamp Function To Format Return Based On Enum
GabeFernandez310 Apr 19, 2023
2ab67ed
Fixed Returned ExprValue
GabeFernandez310 Apr 19, 2023
bbc6526
Reverted Changes To Test Files
GabeFernandez310 Apr 19, 2023
e07b4ca
Reverted Some Changes To Enum And Reworked Code
GabeFernandez310 Apr 19, 2023
dc5ef5b
Added Type Mapping To Allow Query To Be Parsed
GabeFernandez310 Apr 19, 2023
2f45ced
Fixed Some Unit Tests
GabeFernandez310 Apr 19, 2023
d1057e3
Fixed TypeActionMap To Still Support ExprCoreTypes
GabeFernandez310 Apr 20, 2023
225e8a9
Wrapped Some Function Returns in ExprValueFactory
GabeFernandez310 Apr 20, 2023
a7801f4
Fixed Integration Test Bug
GabeFernandez310 Apr 23, 2023
25e9f11
Slight Refactoring And Code Cleanup
GabeFernandez310 Apr 24, 2023
ebbcad2
Removed Unneeded Class Member
GabeFernandez310 Apr 24, 2023
dabf8bc
Removed Unneccessary MappingType Parameters
GabeFernandez310 Apr 24, 2023
be06b94
Refactored Code To Fix Integration Test
GabeFernandez310 Apr 24, 2023
5b879de
Merge branch 'integ-support-date-formats' into dev-support-date-formats
GabeFernandez310 Apr 24, 2023
282cc76
Merge branch 'dev-support-date-formats' of github.com:Bit-Quill/opens…
GabeFernandez310 Apr 24, 2023
0fe9ea0
Addressed JaCoCo Issues
GabeFernandez310 Apr 25, 2023
debda6a
Fixed Checkstyle
GabeFernandez310 Apr 25, 2023
9d4cbfc
Changed gradle version and removed values iterator
GumpacG Apr 25, 2023
568bbf3
Merge branch 'dev-fix-build' of github.com:Bit-Quill/opensearch-proje…
GabeFernandez310 Apr 25, 2023
0fba818
Addressed PR Comments
GabeFernandez310 Apr 25, 2023
c2f7391
Update a test to match new indexResponse.aliases() type.
Apr 26, 2023
6f7e633
Changed To Throw Exception When Encountering Parsing Failures
GabeFernandez310 Apr 26, 2023
a6341ac
Merge branch 'dev-fix-build' of github.com:Bit-Quill/opensearch-proje…
GabeFernandez310 Apr 26, 2023
7fa682e
Fixed Checkstyle
GabeFernandez310 Apr 26, 2023
2a74234
Pull Changes From Upstream
GabeFernandez310 Apr 27, 2023
752a718
Merge branch 'integ-support-date-formats' of github.com:Bit-Quill/ope…
GabeFernandez310 Apr 27, 2023
ace81ea
Removed Unneeded Imports
GabeFernandez310 Apr 27, 2023
2ccebd9
Re-enabled Some Tests
GabeFernandez310 Apr 27, 2023
93f212a
Merge branch 'main' of https://github.com/opensearch-project/sql into…
GumpacG Apr 28, 2023
a3de4e5
Merge branch 'opensearch-project:main' into dev-support-date-formats
GabeFernandez310 Apr 28, 2023
0df21dd
Addressed PR Comments
GabeFernandez310 Apr 28, 2023
28c1bca
Merge branch 'dev-support-date-formats' of github.com:Bit-Quill/opens…
GumpacG Apr 28, 2023
b140170
Changed test data
GumpacG May 1, 2023
e95fdde
Pulled out support for user-defined datetime formats
GumpacG May 3, 2023
4394315
Modified IT test data
GumpacG May 3, 2023
4e9bb15
Added IT tests
GumpacG May 4, 2023
53f4968
Merge branch 'dev-support-date-formats' of github.com:Bit-Quill/opens…
GumpacG May 5, 2023
31a1acc
Removed support for just time and just date formats
GumpacG May 6, 2023
c1dd5d0
Removed unsupported formats from IT
GumpacG May 8, 2023
6dc675c
Removed unit tests for date only or time only formats
GumpacG May 8, 2023
9667574
Addressed PR comments from previous PR
GumpacG May 9, 2023
1fafa8d
Addressed PR comment regarding unnecessary OpenSearchDateType instanc…
GumpacG May 10, 2023
d57ab91
Updates to include build-in date and time formats for OpenSearchDateT…
acarbonetto May 23, 2023
5ddae77
Add tests and fix checkstyle
acarbonetto May 24, 2023
c33fcf0
Fixed bugs regarding custom formats
GumpacG May 24, 2023
0b83204
Add unit test to cover custom formats
acarbonetto May 24, 2023
ca9925e
Fixed rebase conflicts
GumpacG May 24, 2023
52892d0
Addressed PR comments
GumpacG May 25, 2023
80618a8
Fixed checkstyle errors
GumpacG May 25, 2023
2148030
Modified integration test
GumpacG May 25, 2023
21ed35f
Fixed Date and time aggregation
GumpacG May 25, 2023
dde61c1
Fixed failing integ tests
GumpacG May 25, 2023
414159f
Modified integ test based on date format changes
GumpacG May 26, 2023
9250020
Added default formatters for date and time. Added unit tests for cove…
GumpacG May 26, 2023
5f34b39
Some minor review comments
acarbonetto May 29, 2023
c978699
Addressed PR comments
GumpacG May 29, 2023
27c9dd5
Fixed checktsyle and jacoco
GumpacG May 29, 2023
0f0dc96
Changed link in rst file
GumpacG May 29, 2023
2672a79
Changed link in rst file
GumpacG May 29, 2023
58a8f19
Addressed PR comments
GumpacG May 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/user/general/datatypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The table below list the mapping between OpenSearch Data Type, OpenSearch SQL Da
+-----------------+---------------------+-----------+
| text | text | VARCHAR |
+-----------------+---------------------+-----------+
| date | timestamp | TIMESTAMP |
| date* | timestamp | TIMESTAMP |
+-----------------+---------------------+-----------+
| date_nanos | timestamp | TIMESTAMP |
+-----------------+---------------------+-----------+
Expand All @@ -105,6 +105,7 @@ The table below list the mapping between OpenSearch Data Type, OpenSearch SQL Da
+-----------------+---------------------+-----------+

Notes: Not all the OpenSearch SQL Type has correspond OpenSearch Type. e.g. data and time. To use function which required such data type, user should explicitly convert the data type.
date*: Maps to `timestamp` by default. Based on the "format" property `date` can map to `date` or `time`
Yury-Fridlyand marked this conversation as resolved.
Show resolved Hide resolved

Data Type Conversion
====================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ public enum Index {
"calcs",
getMappingFile("calcs_index_mappings.json"),
"src/test/resources/calcs.json"),
DATE_FORMATS(TestsConstants.TEST_INDEX_DATE_FORMATS,
"date_formats",
getMappingFile("date_formats_index_mapping.json"),
"src/test/resources/date_formats.json"),
WILDCARD(TestsConstants.TEST_INDEX_WILDCARD,
"wildcard",
getMappingFile("wildcard_index_mappings.json"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class TestsConstants {
public final static String TEST_INDEX_BEER = TEST_INDEX + "_beer";
public final static String TEST_INDEX_NULL_MISSING = TEST_INDEX + "_null_missing";
public final static String TEST_INDEX_CALCS = TEST_INDEX + "_calcs";
public final static String TEST_INDEX_DATE_FORMATS = TEST_INDEX + "_date_formats";
public final static String TEST_INDEX_WILDCARD = TEST_INDEX + "_wildcard";
public final static String TEST_INDEX_MULTI_NESTED_TYPE = TEST_INDEX + "_multi_nested";
public final static String TEST_INDEX_NESTED_WITH_NULLS = TEST_INDEX + "_nested_with_nulls";
Expand Down
44 changes: 22 additions & 22 deletions integ-test/src/test/java/org/opensearch/sql/sql/AggregationIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,17 @@ public void testAvgDoubleInMemory() throws IOException {

@Test
public void testMaxDatePushedDown() throws IOException {
var response = executeQuery(String.format("SELECT max(CAST(date0 AS date))"
var response = executeQuery(String.format("SELECT max(date0)"
+ " from %s", TEST_INDEX_CALCS));
verifySchema(response, schema("max(CAST(date0 AS date))", null, "date"));
verifySchema(response, schema("max(date0)", null, "date"));
verifyDataRows(response, rows("2004-06-19"));
}

@Test
public void testAvgDatePushedDown() throws IOException {
var response = executeQuery(String.format("SELECT avg(CAST(date0 AS date))"
var response = executeQuery(String.format("SELECT avg(date0)"
+ " from %s", TEST_INDEX_CALCS));
verifySchema(response, schema("avg(CAST(date0 AS date))", null, "date"));
verifySchema(response, schema("avg(date0)", null, "date"));
verifyDataRows(response, rows("1992-04-23"));
}

Expand Down Expand Up @@ -423,25 +423,25 @@ public void testAvgDateTimePushedDown() throws IOException {

@Test
public void testMinTimePushedDown() throws IOException {
var response = executeQuery(String.format("SELECT min(CAST(time1 AS time))"
var response = executeQuery(String.format("SELECT min(time1)"
+ " from %s", TEST_INDEX_CALCS));
verifySchema(response, schema("min(CAST(time1 AS time))", null, "time"));
verifySchema(response, schema("min(time1)", null, "time"));
verifyDataRows(response, rows("00:05:57"));
}

@Test
public void testMaxTimePushedDown() throws IOException {
var response = executeQuery(String.format("SELECT max(CAST(time1 AS time))"
var response = executeQuery(String.format("SELECT max(time1)"
+ " from %s", TEST_INDEX_CALCS));
verifySchema(response, schema("max(CAST(time1 AS time))", null, "time"));
verifySchema(response, schema("max(time1)", null, "time"));
verifyDataRows(response, rows("22:50:16"));
}

@Test
public void testAvgTimePushedDown() throws IOException {
var response = executeQuery(String.format("SELECT avg(CAST(time1 AS time))"
var response = executeQuery(String.format("SELECT avg(time1)"
+ " from %s", TEST_INDEX_CALCS));
verifySchema(response, schema("avg(CAST(time1 AS time))", null, "time"));
verifySchema(response, schema("avg(time1)", null, "time"));
verifyDataRows(response, rows("13:06:36.25"));
}

Expand Down Expand Up @@ -471,28 +471,28 @@ public void testAvgTimeStampPushedDown() throws IOException {

@Test
public void testMinDateInMemory() throws IOException {
var response = executeQuery(String.format("SELECT min(CAST(date0 AS date))"
var response = executeQuery(String.format("SELECT min(date0)"
+ " OVER(PARTITION BY datetime1) from %s", TEST_INDEX_CALCS));
verifySchema(response,
schema("min(CAST(date0 AS date)) OVER(PARTITION BY datetime1)", null, "date"));
schema("min(date0) OVER(PARTITION BY datetime1)", null, "date"));
verifySome(response.getJSONArray("datarows"), rows("1972-07-04"));
}

@Test
public void testMaxDateInMemory() throws IOException {
var response = executeQuery(String.format("SELECT max(CAST(date0 AS date))"
var response = executeQuery(String.format("SELECT max(date0)"
+ " OVER(PARTITION BY datetime1) from %s", TEST_INDEX_CALCS));
verifySchema(response,
schema("max(CAST(date0 AS date)) OVER(PARTITION BY datetime1)", null, "date"));
schema("max(date0) OVER(PARTITION BY datetime1)", null, "date"));
verifySome(response.getJSONArray("datarows"), rows("2004-06-19"));
}

@Test
public void testAvgDateInMemory() throws IOException {
var response = executeQuery(String.format("SELECT avg(CAST(date0 AS date))"
var response = executeQuery(String.format("SELECT avg(date0)"
+ " OVER(PARTITION BY datetime1) from %s", TEST_INDEX_CALCS));
verifySchema(response,
schema("avg(CAST(date0 AS date)) OVER(PARTITION BY datetime1)", null, "date"));
schema("avg(date0) OVER(PARTITION BY datetime1)", null, "date"));
verifySome(response.getJSONArray("datarows"), rows("1992-04-23"));
}

Expand Down Expand Up @@ -525,28 +525,28 @@ public void testAvgDateTimeInMemory() throws IOException {

@Test
public void testMinTimeInMemory() throws IOException {
var response = executeQuery(String.format("SELECT min(CAST(time1 AS time))"
var response = executeQuery(String.format("SELECT min(time1)"
+ " OVER(PARTITION BY datetime1) from %s", TEST_INDEX_CALCS));
verifySchema(response,
schema("min(CAST(time1 AS time)) OVER(PARTITION BY datetime1)", null, "time"));
schema("min(time1) OVER(PARTITION BY datetime1)", null, "time"));
verifySome(response.getJSONArray("datarows"), rows("00:05:57"));
}

@Test
public void testMaxTimeInMemory() throws IOException {
var response = executeQuery(String.format("SELECT max(CAST(time1 AS time))"
var response = executeQuery(String.format("SELECT max(time1)"
+ " OVER(PARTITION BY datetime1) from %s", TEST_INDEX_CALCS));
verifySchema(response,
schema("max(CAST(time1 AS time)) OVER(PARTITION BY datetime1)", null, "time"));
schema("max(time1) OVER(PARTITION BY datetime1)", null, "time"));
verifySome(response.getJSONArray("datarows"), rows("22:50:16"));
}

@Test
public void testAvgTimeInMemory() throws IOException {
var response = executeQuery(String.format("SELECT avg(CAST(time1 AS time))"
var response = executeQuery(String.format("SELECT avg(time1)"
+ " OVER(PARTITION BY datetime1) from %s", TEST_INDEX_CALCS));
verifySchema(response,
schema("avg(CAST(time1 AS time)) OVER(PARTITION BY datetime1)", null, "time"));
schema("avg(time1) OVER(PARTITION BY datetime1)", null, "time"));
verifySome(response.getJSONArray("datarows"), rows("13:06:36.25"));
}

Expand Down
Loading