-
Notifications
You must be signed in to change notification settings - Fork 0
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
[JDBC
] Fix precision returned for datetime columns
#178
Conversation
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
@@ -98,6 +99,26 @@ public ResultSetImpl(StatementImpl statement, List<? extends ColumnDescriptor> c | |||
|
|||
List<Row> rows = getRowsFromDataRows(dataRows); | |||
|
|||
for (int i = 0; i < columnDescriptors.size(); i ++) { | |||
if (schema.getOpenSearchType(i) == OpenSearchType.TIMESTAMP || |
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.
if this is an enum, its better practice to use a switch
@@ -98,6 +99,26 @@ public ResultSetImpl(StatementImpl statement, List<? extends ColumnDescriptor> c | |||
|
|||
List<Row> rows = getRowsFromDataRows(dataRows); | |||
|
|||
for (int i = 0; i < columnDescriptors.size(); i ++) { |
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.
you can use array streams to filter the columns by type (DATE|TIME|DATETIME), and then get the max value row for that column.
Then you don't have to include a double for loop
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.
Should we check to see if the Precision is already defined in the metadata beforehand?
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.
Should we check to see if the Precision is already defined in the metadata beforehand?
No, I change the constructor.
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.
Then you don't have to include a double for loop
I have to loop through all rows/columns anyway
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.
Can we talk about this approach? I see what you're doing, but I have some thoughts about the pros/cons.
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.
For sure!
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Codecov Report
@@ Coverage Diff @@
## integ-fix-#1003 opensearch-project/sql#178 +/- ##
==================================================
Coverage ? 95.78%
Complexity ? 3465
==================================================
Files ? 357
Lines ? 9305
Branches ? 669
==================================================
Hits ? 8913
Misses ? 334
Partials ? 58
Flags with carried forward coverage won't be shown. Click here to find out more. 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
JDBC
] Fix precision returned for datetime columns
@Yury-Fridlyand why is this the best solution? What are other options? Seems strange that we cannot derive precision of a timestamp from OpenSearch type information. |
I was waiting for this question!
Return fixed values, but more realistic.
There is no such information, unless we change the server side to provide it.
First 3 columns have the same type, but different I dislike the solution I proposed, but I have no idea how to do this better. You are welcome to share your thoughts! |
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
…Time` has no FSP. Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Discussed offline.
Fix is is implemented in 6a495cb in scope of opensearch-project#185. |
Signed-off-by: Yury-Fridlyand yuryf@bitquilltech.com
Description
The proposed fix add calculation of
Precision
for datetime types in runtime for each dataset.To optimize performance, analysis goes over first 1000 rows of dataset and stop earlier if
precision
calculated with enough precision - on 100 entries for good statistics.Test
Before
After
Issues Resolved
opensearch-project/sql-jdbc#19
Check List
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.