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