Github user vvysotskyi commented on a diff in the pull request:
https://github.com/apache/drill/pull/570#discussion_r161004122
--- Diff:
exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java ---
@@ -68,15 +68,31 @@ public void setup() {
public void eval() {
out.scale = (int) scale.value;
+
+ <#if !type.to.endsWith("VarDecimal")>
out.precision = (int) precision.value;
+ </#if>
- <#if type.to == "Decimal9" || type.to == "Decimal18">
+ <#if type.to.endsWith("VarDecimal")>
+ out.start = 0;
+ out.buffer = buffer;
+ String s = Long.toString((long)in.value);
+ for (int i = 0; i < out.scale; ++i) { // add 0's to get unscaled
integer
+ s += "0";
+ }
+ java.math.BigInteger bi = new java.math.BigInteger(s);
+ java.math.BigDecimal bd = new java.math.BigDecimal(bi, out.scale);
+ //System.out.println("CastIntDecimal in " + in.value + " scale " +
out.scale + " string " + s + " bd " + bd);
--- End diff --
Please remove this comment.
---