-
Notifications
You must be signed in to change notification settings - Fork 141
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
Fix a regression issue of parsing datetime string with custom time format in Span #3079
Conversation
Signed-off-by: Lantao Jin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please increase unit test coverage and resolve now failing integration tests.
jacoco results
-----------
* What went wrong:
Execution failed for task ':core:jacocoTestCoverageVerification'.
> Rule violated for class org.opensearch.sql.planner.physical.collector.Rounding: branches covered ratio is 0.8, but expected minimum is 1.0
test failures
DateTimeFormatsIT > testIncompleteFormats FAILED
java.lang.AssertionError:
Expected: iterable with items [[1984-01-01 00:00:00, null, null, 10:00:00, 1999-01-01], [2012-01-01 00:00:00, null, null, 20:00:00, 3021-01-01]] in any order
but: not matched: <["1984-01-01 00:00:00",null,null,"1970-01-01","1999-01-01"]>
at __randomizedtesting.SeedInfo.seed([2C68C17CE23C9F5D:B917EF6B60642A6C]:0)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
at org.opensearch.sql.util.MatcherUtils.verify(MatcherUtils.java:188)
at org.opensearch.sql.util.MatcherUtils.verifyDataRows(MatcherUtils.java:159)
at org.opensearch.sql.sql.DateTimeFormatsIT.testIncompleteFormats(DateTimeFormatsIT.java:124)
DateTimeFormatsIT > testCustomFormats FAILED
java.lang.AssertionError:
Expected: iterable with items [[09:07:42, 1984-04-12 09:07:42, 1984-04-12, 1961-04-12 00:00:00, 23:44:36.321], [21:07:42, 1984-04-12 22:07:42, 1984-04-12, 1970-01-01 09:07:00, 09:01:16.542]] in any order
but: not matched: <["09:07:42","1984-04-12 09:07:42","1984-04-12","1961-04-12","1970-01-01"]>
at __randomizedtesting.SeedInfo.seed([2C68C17CE23C9F5D:203B87710DB1C56E]:0)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
at org.opensearch.sql.util.MatcherUtils.verify(MatcherUtils.java:188)
at org.opensearch.sql.util.MatcherUtils.verifyDataRows(MatcherUtils.java:159)
at org.opensearch.sql.sql.DateTimeFormatsIT.testCustomFormats(DateTimeFormatsIT.java:76)
DateTimeFormatsIT > testDateFormatsWithOr FAILED
java.lang.AssertionError:
Expected: iterable with items [[1984-04-12 00:00:00], [1984-04-12 09:07:42.000123456]] in any order
but: not matched: <["1984-04-12"]>
at __randomizedtesting.SeedInfo.seed([2C68C17CE23C9F5D:51D930CA323C2C64]:0)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
at org.opensearch.sql.util.MatcherUtils.verify(MatcherUtils.java:188)
at org.opensearch.sql.util.MatcherUtils.verifyDataRows(MatcherUtils.java:159)
at org.opensearch.sql.sql.DateTimeFormatsIT.testDateFormatsWithOr(DateTimeFormatsIT.java:57)
DateTimeFormatsIT > testDateNanosWithNanos PASSED
DateTimeFormatsIT > testCustomFormats2 FAILED
java.lang.AssertionError:
Expected: iterable with items [[1984-10-20, 10:20:30, 1984-10-20 15:35:48], [1961-04-12, 09:07:00, 1961-04-12 09:07:00]] in any order
but: not matched: <["1970-01-01","1970-01-01","2598-09-26"]>
at __randomizedtesting.SeedInfo.seed([2C68C17CE23C9F5D:75DB39273E844970]:0)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
at org.opensearch.sql.util.MatcherUtils.verify(MatcherUtils.java:188)
at org.opensearch.sql.util.MatcherUtils.verifyDataRows(MatcherUtils.java:159)
at org.opensearch.sql.sql.DateTimeFormatsIT.testCustomFormats2(DateTimeFormatsIT.java:102)
Signed-off-by: Lantao Jin <[email protected]>
The unit test coverage can't be fixed since jacoco report is module-level based. What's the bug here is missing the |
@YANG-DB @MaxKsyunz @penghuo , since this seems a regression issue introduced from v2.16.0. I'd like this fixing could be merged in v2.18.0 |
Signed-off-by: Lantao Jin <[email protected]>
core/src/main/java/org/opensearch/sql/planner/physical/collector/Rounding.java
Show resolved
Hide resolved
@@ -295,7 +295,7 @@ private static ExprValue createOpenSearchDateType(Content value, ExprType type) | |||
} | |||
} else { | |||
// custom format | |||
return parseDateTimeString(value.stringValue(), dt); | |||
return parseDateTimeString(value.objectValue().toString(), dt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could u elberate more? value is number value? why objectValue().toString()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is an instance of ObjectContent
and isNumber() is true, stringValue()
will return the string representation of the object, such as ObjectContent@1234
. We should convert it to Java Object then use toString()
here. Or value.longValue().toString()
. Not sure the value here is a Long type, so value.objectValue().toString()
would be best.
could u exclude Rounding from TestCoverage and address it later. otherwise, following PR will failed with test coverage? |
Excluding Does anyone else could help to confirm?^ cc @dai-chen @ykmr1224 |
Signed-off-by: Lantao Jin <[email protected]>
I added some unit tests in a mock way to fix the missing test coverage. Now CI passed! Please take a review again @YANG-DB @MaxKsyunz @penghuo @dai-chen @ykmr1224. This patch could be marked as critical for 2.18.0! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx!
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.x
# Create a new branch
git switch --create backport/backport-3079-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 4ff1fe3cb48a17ff17b0cf134131283fc0282205
# Push it to GitHub
git push --set-upstream origin backport/backport-3079-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.x Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.18 2.18
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.18
# Create a new branch
git switch --create backport/backport-3079-to-2.18
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 4ff1fe3cb48a17ff17b0cf134131283fc0282205
# Push it to GitHub
git push --set-upstream origin backport/backport-3079-to-2.18
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.18 Then, create a pull request where the |
…rmat in Span (opensearch-project#3079) (cherry picked from commit 4ff1fe3)
…rmat in Span (opensearch-project#3079) (cherry picked from commit 4ff1fe3)
… custom time format in Span (#3079) (#3146) * Fix a regression issue of parsing datetime string with custom time format in Span (#3079) (cherry picked from commit 4ff1fe3) * fix compile error Signed-off-by: Lantao Jin <[email protected]> * fix coverage Signed-off-by: Lantao Jin <[email protected]> --------- Signed-off-by: Lantao Jin <[email protected]>
Description
This seems a regression issue from #2762. Query of StatsBy with Span on a custom formatted date type will fail.
Here is the reproduce:
Throws NPE.
Related Issues
Resolves #3078
Check List
--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.