[JDBC] Fix precision returned for datetime columns#178
[JDBC] Fix precision returned for datetime columns#178Yury-Fridlyand wants to merge 8 commits intointeg-fix-#1003from
JDBC] Fix precision returned for datetime columns#178Conversation
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
| 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.
if this is an enum, its better practice to use a switch
|
|
||
| List<Row> rows = getRowsFromDataRows(dataRows); | ||
|
|
||
| for (int i = 0; i < columnDescriptors.size(); i ++) { |
There was a problem hiding this comment.
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.
Should we check to see if the Precision is already defined in the metadata beforehand?
There was a problem hiding this comment.
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.
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.
Can we talk about this approach? I see what you're doing, but I have some thoughts about the pros/cons.
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
Precisionfor datetime types in runtime for each dataset.To optimize performance, analysis goes over first 1000 rows of dataset and stop earlier if
precisioncalculated 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.