You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/09 08:21:27 UTC

[GitHub] [arrow] liyafan82 commented on a change in pull request #12294: ARROW-15501: [Java] Support validating decimal vectors

liyafan82 commented on a change in pull request #12294:
URL: https://github.com/apache/arrow/pull/12294#discussion_r802380638



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorTypeVisitor.java
##########
@@ -116,6 +116,25 @@ private void validateDateVector(ValueVector vector, DateUnit expectedDateUnit) {
         "Expecting date unit %s, actual date unit %s.", expectedDateUnit, dateType.getUnit());
   }
 
+  private void validateDecimalVector(ValueVector vector) {
+    validateOrThrow(vector.getField().getFieldType().getType() instanceof ArrowType.Decimal,
+            "Vector %s is not a decimal vector", vector.getClass());
+    ArrowType.Decimal decimalType = (ArrowType.Decimal) vector.getField().getFieldType().getType();
+    validateOrThrow(decimalType.getScale() >= 0, "The scale of decimal %s is negative.", decimalType.getScale());

Review comment:
       Good point. Thanks. 
   Added a check for that and a test case for it. 




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

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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