drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vvysotskyi <...@git.apache.org>
Subject [GitHub] drill pull request #570: DRILL-4834 decimal implementation is vulnerable to ...
Date Tue, 09 Jan 2018 18:52:03 GMT
Github user vvysotskyi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/570#discussion_r160465652
  
    --- 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";
    --- End diff --
    
    I think the usage of `StringBuilder` will be more suitable here.


---

Mime
View raw message