You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by vvysotskyi <gi...@git.apache.org> on 2018/01/09 18:52:02 UTC
[GitHub] drill pull request #570: DRILL-4834 decimal implementation is vulnerable to ...
Github user vvysotskyi commented on a diff in the pull request:
https://github.com/apache/drill/pull/570#discussion_r160458242
--- Diff: exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarchar.java ---
@@ -150,6 +150,14 @@ public void setup() {
public void eval() {
+<#if type.from.contains("VarDecimal")>
+ java.math.BigDecimal bigDecimal = org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromDrillBuf(in.buffer, in.start, in.end - in.start, in.scale);
+ String str = bigDecimal.toString();
+ out.buffer = buffer;
+ out.start = 0;
+ out.end = Math.min((int)len.value, str.length());
+ out.buffer.setBytes(0, str.getBytes());
--- End diff --
What about the case when `str` has a length greater than `len`? I think it would be better to use `setBytes(int index, byte[] src, int srcIndex, int length)` method here.
---