Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/1026#discussion_r150359625
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/JsonConvertTo.java
---
@@ -90,7 +91,71 @@ public void eval(){
java.io.ByteArrayOutputStream stream = new
java.io.ByteArrayOutputStream();
try {
- org.apache.drill.exec.vector.complex.fn.JsonWriter jsonWriter =
new org.apache.drill.exec.vector.complex.fn.JsonWriter(stream, true, true);
+ org.apache.drill.exec.vector.complex.fn.JsonWriter jsonWriter =
new org.apache.drill.exec.vector.complex.fn.JsonWriter(stream, true, true,
false);
+
+ jsonWriter.write(input);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ byte [] bytea = stream.toByteArray();
+
+ out.buffer = buffer = buffer.reallocIfNeeded(bytea.length);
+ out.buffer.setBytes(0, bytea);
+ out.end = bytea.length;
+ }
+ }
+
+ @FunctionTemplate(names = { "convert_toJSON", "convert_toSIMPLEJSON" } ,
scope = FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
+ public static class ConvertToJsonNonNumeric implements DrillSimpleFunc{
+
+ @Param FieldReader input;
+ @Param BitHolder nonNumeric;
+ @Output VarBinaryHolder out;
+ @Inject DrillBuf buffer;
+
+ public void setup(){
+ }
+
+ public void eval(){
+ out.start = 0;
+
+ java.io.ByteArrayOutputStream stream = new
java.io.ByteArrayOutputStream();
+ try {
+ org.apache.drill.exec.vector.complex.fn.JsonWriter jsonWriter =
new org.apache.drill.exec.vector.complex.fn.JsonWriter(stream, true, false,
--- End diff --
More copies.
---