drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] vvysotskyi commented on a change in pull request #2006: DRILL-7615: UNION ALL query returns the wrong result for the decimal value
Date Tue, 03 Mar 2020 13:35:33 GMT
vvysotskyi commented on a change in pull request #2006: DRILL-7615: UNION ALL query returns
the wrong result for the decimal value
URL: https://github.com/apache/drill/pull/2006#discussion_r386928587
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java
 ##########
 @@ -184,38 +184,43 @@ private void createUnionAller(RecordBatch inputBatch) {
       ValueVector vvIn = vw.getValueVector();
       ValueVector vvOut = container.getValueVector(index).getValueVector();
 
-      final ErrorCollector collector = new ErrorCollectorImpl();
-      // According to input data names, Minortypes, Datamodes, choose to
+      MaterializedField inField = vvIn.getField();
+      MaterializedField outputField = vvOut.getField();
+
+      ErrorCollector collector = new ErrorCollectorImpl();
+      // According to input data names, MinorTypes, DataModes, choose to
       // transfer directly,
       // rename columns or
-      // cast data types (Minortype or DataMode)
-      if (container.getSchema().getColumn(index).hasSameTypeAndMode(vvIn.getField())
-          && vvIn.getField().getType().getMinorType() != TypeProtos.MinorType.MAP
// Per DRILL-5521, existing bug for map transfer
-          ) {
+      // cast data types (MinorType or DataMode)
+      if (outputField.hasSameTypeAndMode(inField)
+          && inField.getType().getMinorType() != TypeProtos.MinorType.MAP // Per
DRILL-5521, existing bug for map transfer
+          && (!Types.areDecimalTypes(inField.getType(), outputField.getType())
+              || (Types.areDecimalTypes(outputField.getType(), inField.getType()) // scale
should match for decimal data types
+                  && outputField.getType().getScale() == inField.getType().getScale())))
{
 
 Review comment:
   For Decimal data type, the scale is only essential here, since data transfer may be done
for the case of different precisions without corrupting the data. Extracted whole this condition
into a separate method to make code more readable.

----------------------------------------------------------------
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


With regards,
Apache Git Services

Mime
View raw message