You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2021/03/27 14:28:25 UTC

[GitHub] [drill] vvysotskyi opened a new pull request #2193: DRILL-7887: JDBC plugin returns incorrect precision for SUM(DECIMAL) queries

vvysotskyi opened a new pull request #2193:
URL: https://github.com/apache/drill/pull/2193


   # [DRILL-7887](https://issues.apache.org/jira/browse/DRILL-7887): JDBC plugin returns incorrect precision for SUM(DECIMAL) queries
   
   ## Description
   Made changes to return DRILL_REL_DATATYPE_SYSTEM.getMaxNumericScale() and DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision() for the case when JDBC calculated presision is greater to avoid errors in Drill.
   Also, added a check for actual value scale and precision to avoid returning incorrect values. 
   
   ## Documentation
   NA
   
   ## Testing
   Added unit test to check the desired behavior.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] luocooong commented on a change in pull request #2193: DRILL-7887: JDBC plugin returns incorrect precision for SUM(DECIMAL) queries

Posted by GitBox <gi...@apache.org>.
luocooong commented on a change in pull request #2193:
URL: https://github.com/apache/drill/pull/2193#discussion_r602738548



##########
File path: contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
##########
@@ -210,8 +212,8 @@ public void setup(OperatorContext operatorContext, OutputMutator output) {
         String name = columns.get(i - 1).getRootSegmentPath();
         // column index in ResultSetMetaData starts from 1
         int jdbcType = meta.getColumnType(i);
-        int width = meta.getPrecision(i);
-        int scale = meta.getScale(i);
+        int width = Math.min(meta.getPrecision(i), DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision());

Review comment:
       Nice idea. Is it possible to add the description of UDF (with the limitation of precision) in the [JDBC](https://github.com/apache/drill/blob/gh-pages/_docs/connect-a-data-source/plugins/080-rdbms-storage-plugin.md) docs?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] vvysotskyi commented on a change in pull request #2193: DRILL-7887: JDBC plugin returns incorrect precision for SUM(DECIMAL) queries

Posted by GitBox <gi...@apache.org>.
vvysotskyi commented on a change in pull request #2193:
URL: https://github.com/apache/drill/pull/2193#discussion_r602750741



##########
File path: contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
##########
@@ -210,8 +212,8 @@ public void setup(OperatorContext operatorContext, OutputMutator output) {
         String name = columns.get(i - 1).getRootSegmentPath();
         // column index in ResultSetMetaData starts from 1
         int jdbcType = meta.getColumnType(i);
-        int width = meta.getPrecision(i);
-        int scale = meta.getScale(i);
+        int width = Math.min(meta.getPrecision(i), DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision());

Review comment:
       We already have `round()` UDF description at https://drill.apache.org/docs/math-and-trig/




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre merged pull request #2193: DRILL-7887: JDBC plugin returns incorrect precision for SUM(DECIMAL) queries

Posted by GitBox <gi...@apache.org>.
cgivre merged pull request #2193:
URL: https://github.com/apache/drill/pull/2193


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] luocooong commented on a change in pull request #2193: DRILL-7887: JDBC plugin returns incorrect precision for SUM(DECIMAL) queries

Posted by GitBox <gi...@apache.org>.
luocooong commented on a change in pull request #2193:
URL: https://github.com/apache/drill/pull/2193#discussion_r602734638



##########
File path: contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
##########
@@ -210,8 +212,8 @@ public void setup(OperatorContext operatorContext, OutputMutator output) {
         String name = columns.get(i - 1).getRootSegmentPath();
         // column index in ResultSetMetaData starts from 1
         int jdbcType = meta.getColumnType(i);
-        int width = meta.getPrecision(i);
-        int scale = meta.getScale(i);
+        int width = Math.min(meta.getPrecision(i), DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision());

Review comment:
       The function of `min()` is to prevent the precision of the back-end database from exceeding the limit of Drill, so a selection is required, Is right?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] vvysotskyi commented on a change in pull request #2193: DRILL-7887: JDBC plugin returns incorrect precision for SUM(DECIMAL) queries

Posted by GitBox <gi...@apache.org>.
vvysotskyi commented on a change in pull request #2193:
URL: https://github.com/apache/drill/pull/2193#discussion_r602735891



##########
File path: contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
##########
@@ -210,8 +212,8 @@ public void setup(OperatorContext operatorContext, OutputMutator output) {
         String name = columns.get(i - 1).getRootSegmentPath();
         // column index in ResultSetMetaData starts from 1
         int jdbcType = meta.getColumnType(i);
-        int width = meta.getPrecision(i);
-        int scale = meta.getScale(i);
+        int width = Math.min(meta.getPrecision(i), DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision());

Review comment:
       Very often the precision from the type is much less than the precision of the actual values, so with these changes, Drill will be able to process such values. But if the actual value also has large precision, the exception added below will be thrown, and as pointed in the error message, the user may use `round()` UDF to fix such a case.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org