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

Update DATE and TIME functions to parse string input as datetime #991

Merged
merged 21 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
65c34ac
Added test cases and support for strict date validation. Added abilit…
MitchellGale Oct 13, 2022
4a4e425
Update `ExprTimeValue` by `datetimeValue` and other interfaces. Add c…
Yury-Fridlyand Oct 13, 2022
da22234
core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFun…
Yury-Fridlyand Oct 13, 2022
e421349
Fix conversion to timestamp.
Yury-Fridlyand Oct 14, 2022
26c1165
Added try catch to return null for invalid date in DATE
MitchellGale Oct 17, 2022
be3ea22
Added null test for TIME and DATE
MitchellGale Oct 17, 2022
4f7edd1
Added exprDate to accept time.
MitchellGale Oct 17, 2022
a00863c
Accept date time for time and date
MitchellGale Oct 18, 2022
99c98b0
Adding coverage
MitchellGale Oct 19, 2022
f9e38e9
Fixed code coverage for time passed to date function case.
MitchellGale Oct 19, 2022
2016222
Adding more test cases for datetime and milliseconds for DATE and TIM…
MitchellGale Oct 19, 2022
4c0928d
Removed unused imports.
MitchellGale Oct 19, 2022
95c5e5c
Removed unused DATETIMEFORMATTERS.
MitchellGale Oct 20, 2022
61289bb
Added support for HH:mm for time/datetime inputs. Removed call for lo…
MitchellGale Oct 25, 2022
310f653
Added more doc tests.
MitchellGale Oct 27, 2022
484b28c
Removed blocks from cherry-picked PR.
MitchellGale Oct 28, 2022
157059f
Reverted change in ExprDateTimeValue
MitchellGale Oct 28, 2022
77bd46e
Reverted reverted changes in ExprDateTimeValue. Reverted change in Ex…
MitchellGale Oct 28, 2022
bc1507c
Merge pull request #134 from Bit-Quill/dev-updateTimeFunction
MitchellGale Oct 31, 2022
ae241b6
Moved to throwing exception instead of returning null in Date and Tim…
MitchellGale Nov 3, 2022
68b9a26
Removed redundant exprTime check for date.
MitchellGale Nov 8, 2022
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
Prev Previous commit
Next Next commit
Fix conversion to timestamp.
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored and MitchellGale committed Oct 14, 2022
commit e42134952915e1c98473f6a8cb2aab55c7aa7a28
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public LocalDateTime datetimeValue() {

@Override
public Instant timestampValue() {
return ZonedDateTime.of(date, timeValue(), ZoneId.systemDefault()).toInstant();
return ZonedDateTime.of(date, timeValue(), ZoneId.of("UTC")).toInstant();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public LocalDateTime datetimeValue() {

@Override
public Instant timestampValue() {
return ZonedDateTime.of(dateValue(), timeValue(), ZoneId.systemDefault()).toInstant();
return ZonedDateTime.of(dateValue(), timeValue(), ZoneId.of("UTC")).toInstant();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void timeValueInterfaceTest() {
assertEquals(LocalDate.now(), timeValue.dateValue());
assertEquals(LocalDate.now().atTime(1, 1, 1), timeValue.datetimeValue());
assertEquals(ZonedDateTime.of(LocalTime.parse("01:01:01").atDate(LocalDate.now()),
ZoneId.systemDefault()).toInstant(), timeValue.timestampValue());
ZoneId.of("UTC")).toInstant(), timeValue.timestampValue());
assertEquals("01:01:01", timeValue.value());
assertEquals("TIME '01:01:01'", timeValue.toString());
assertThrows(ExpressionEvaluationException.class, () -> integerValue(1).timeValue(),
Expand Down Expand Up @@ -65,7 +65,7 @@ public void dateValueInterfaceTest() {
assertEquals(LocalTime.parse("00:00:00"), dateValue.timeValue());
assertEquals(LocalDateTime.parse("2012-07-07T00:00:00"), dateValue.datetimeValue());
assertEquals(ZonedDateTime.of(LocalDateTime.parse("2012-07-07T00:00:00"),
ZoneId.systemDefault()).toInstant(), dateValue.timestampValue());
ZoneId.of("UTC")).toInstant(), dateValue.timestampValue());
ExpressionEvaluationException exception =
assertThrows(ExpressionEvaluationException.class, () -> integerValue(1).dateValue());
assertEquals("invalid to get dateValue from value of type INTEGER",
Expand Down