ggangadharan commented on code in PR #6878:
URL: https://github.com/apache/hive/pull/6878#discussion_r4295135434
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TruncDecimal.java:
##########
@@ -45,26 +44,8 @@ public TruncDecimal(int colNum, int scale, int
outputColumnNum) {
@Override
protected void trunc(ColumnVector inputColVector, ColumnVector
outputColVector, int i) {
- HiveDecimal input = ((DecimalColumnVector)
inputColVector).vector[i].getHiveDecimal();
-
- HiveDecimal output = trunc(input);
- ((DecimalColumnVector) outputColVector).vector[i] = new
HiveDecimalWritable(output);
- }
-
- protected HiveDecimal trunc(HiveDecimal input) {
- HiveDecimal pow = HiveDecimal.create(Math.pow(10, Math.abs(scale)));
-
- if (scale >= 0) {
- if (scale != 0) {
- long longValue = input.multiply(pow).longValue();
- return HiveDecimal.create(longValue).divide(pow);
- } else {
- return HiveDecimal.create(input.longValue());
- }
- } else {
- long longValue2 = input.divide(pow).longValue();
- return HiveDecimal.create(longValue2).multiply(pow);
- }
+ TruncUtils.trunc(((DecimalColumnVector) inputColVector).vector[i], scale,
Review Comment:
Done, TruncDecimal now reads the input into a local first, same as
TruncFloat.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]