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

[DRAFT] [JDBC] Fix ResultSet.getTime() #192

Closed

Conversation

margarit-h
Copy link

@margarit-h margarit-h commented Dec 16, 2022

Signed-off-by: Margarit Hakobyan [email protected]

Description

ResultSet.getTime() returns non-null value reflecting the retrieved time instead of null.
PR in sql-jdbc repo https://github.com/Bit-Quill/sql-jdbc/pull/1/files

Issues Resolved

opensearch-project/sql-jdbc#20

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.

@margarit-h margarit-h changed the title Fix Result.Set.getTime() [WIP:] Fix Result.Set.getTime() Dec 16, 2022
@margarit-h margarit-h changed the title [WIP:] Fix Result.Set.getTime() [WIP:] Fix ResultSet.getTime() Dec 16, 2022
@margarit-h margarit-h changed the title [WIP:] Fix ResultSet.getTime() [WIP:] [JDBC] Fix ResultSet.getTime() Dec 16, 2022
@codecov
Copy link

codecov bot commented Dec 16, 2022

Codecov Report

Merging #192 (aad073b) into integ-fix-resultset-get-time (18661b4) will decrease coverage by 2.48%.
The diff coverage is n/a.

@@                        Coverage Diff                         @@
##             integ-fix-resultset-get-time     #192      +/-   ##
==================================================================
- Coverage                           98.32%   95.83%   -2.49%     
  Complexity                           3552     3552              
==================================================================
  Files                                 346      356      +10     
  Lines                                8756     9414     +658     
  Branches                              554      673     +119     
==================================================================
+ Hits                                 8609     9022     +413     
- Misses                                142      334     +192     
- Partials                                5       58      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
workbench/public/components/Header/Header.tsx 100.00% <0.00%> (ø)
...ublic/components/QueryResults/QueryResultsBody.tsx 68.32% <0.00%> (ø)
workbench/public/application.tsx 0.00% <0.00%> (ø)
workbench/public/components/SQLPage/SQLPage.tsx 100.00% <0.00%> (ø)
workbench/public/utils/PanelWrapper.tsx 100.00% <0.00%> (ø)
...ch/public/components/QueryResults/QueryResults.tsx 61.60% <0.00%> (ø)
...h/public/components/QueryLanguageSwitch/Switch.tsx 85.71% <0.00%> (ø)
workbench/public/components/app.tsx 0.00% <0.00%> (ø)
workbench/public/components/PPLPage/PPLPage.tsx 56.52% <0.00%> (ø)
workbench/public/components/Main/main.tsx 53.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@margarit-h margarit-h marked this pull request as draft December 16, 2022 23:02
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
log.debug(() -> logEntry("getTime (%d, %s)", columnIndex,
cal == null ? "null" : "Calendar TZ= " + cal.getTimeZone()));
checkCursorOperationPossible();
Time value = getTimeX(columnIndex, cal);

Choose a reason for hiding this comment

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

this will get called with or without debug. Can we put this in the log.debug() statement below?

log.debug(() -> logExit("getTime", getTimeX(columnIndex, cal)));

cal == null ? "null" : "Calendar TZ= " + cal.getTimeZone()));
checkCursorOperationPossible();
Time value = getTimeX(getColumnIndex(columnLabel), cal);
log.debug(() -> logExit("getTime", value));

Choose a reason for hiding this comment

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

same here?

public Time asTime(String value) throws SQLException {
return localTimetoSqlTime(toLocalTime(value));
}
if (value.length() > 10) {

Choose a reason for hiding this comment

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

instead of checking for length, can we try..catch an error from DateTimeFormatter if the pattern doesn't match?

@acarbonetto
Copy link

related: opensearch-project/sql-jdbc#20

Signed-off-by: Margarit Hakobyan <[email protected]>
checkCursorOperationPossible();
log.debug(() -> {
try {
return logExit("getTime", getTimeX(columnIndex, cal));

Choose a reason for hiding this comment

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

Whoops. This is not right. I misunderstood, and thought getTimeX was only needed for debug calls... but we certainly don't want this. We should only call getTimeX once. Please revert this back to what you had before.

checkCursorOperationPossible();
log.debug(() -> {
try {
return logExit("getTime", getTimeX(getColumnIndex(columnLabel), cal));

Choose a reason for hiding this comment

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

same here. We really should only call getTimeX once.

Signed-off-by: Margarit Hakobyan <[email protected]>
@margarit-h margarit-h changed the title [WIP:] [JDBC] Fix ResultSet.getTime() [DRAFT] [JDBC] Fix ResultSet.getTime() Jan 3, 2023
Comment on lines +57 to +59
} catch (DateTimeParseException exception) {
time = Time.valueOf(value);
}

Choose a reason for hiding this comment

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

When it can fallback to catch block? Won't it throw an exception from there if value is not convertable to Time?

@margarit-h margarit-h closed this Jan 5, 2023
@margarit-h
Copy link
Author

An upstream PR in sql-jdbc repo got merged. opensearch-project/sql-jdbc#41

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.

4 participants