You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/06/07 14:21:00 UTC

[jira] [Commented] (DRILL-8239) Convert JSON UDF to EVF

    [ https://issues.apache.org/jira/browse/DRILL-8239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17551117#comment-17551117 ] 

ASF GitHub Bot commented on DRILL-8239:
---------------------------------------

vdiravka commented on code in PR #2567:
URL: https://github.com/apache/drill/pull/2567#discussion_r891297158


##########
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/JsonConvertFrom.java:
##########
@@ -32,37 +30,45 @@
 import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.expr.holders.VarCharHolder;
+import org.apache.drill.exec.physical.resultSet.ResultSetLoader;
+import org.apache.drill.exec.server.options.OptionManager;
 import org.apache.drill.exec.vector.complex.writer.BaseWriter.ComplexWriter;
 
 public class JsonConvertFrom {
 
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JsonConvertFrom.class);
-
   private JsonConvertFrom() {
   }
 
   @FunctionTemplate(name = "convert_fromJSON", scope = FunctionScope.SIMPLE, isRandom = true)
   public static class ConvertFromJson implements DrillSimpleFunc {
 
     @Param VarBinaryHolder in;
-    @Inject DrillBuf buffer;
-    @Workspace org.apache.drill.exec.vector.complex.fn.JsonReader jsonReader;
+    @Inject
+    ResultSetLoader loader;
+    @Workspace
+    org.apache.drill.exec.store.easy.json.loader.JsonLoaderImpl.JsonLoaderBuilder jsonLoaderBuilder;
+
+    @Inject
+    OptionManager options;
 
     @Output ComplexWriter writer;
 
     @Override
     public void setup() {
-      jsonReader = new org.apache.drill.exec.vector.complex.fn.JsonReader.Builder(buffer)
-          .defaultSchemaPathColumns()
-          .build();
+      jsonLoaderBuilder = new org.apache.drill.exec.store.easy.json.loader.JsonLoaderImpl.JsonLoaderBuilder()
+        .resultSetLoader(loader)
+        .standardOptions(options);
     }
 
     @Override
     public void eval() {
       try {
-        jsonReader.setSource(in.start, in.end, in.buffer);
-        jsonReader.write(writer);
-        buffer = jsonReader.getWorkBuf();
+        jsonLoaderBuilder.fromStream(in.start, in.end, in.buffer);
+        org.apache.drill.exec.store.easy.json.loader.JsonLoader jsonLoader = jsonLoaderBuilder.build();
+        loader.startBatch();
+        jsonLoader.readBatch();
+        loader.close();

Review Comment:
   It shouldn't be closed in the `eval` part of the UDF, because `loader` is using in `ProjectRecordBatch` and creating the function output. And it is actually is closing in `ProjectRecordBatch` after #2568 merged





> Convert JSON UDF to EVF
> -----------------------
>
>                 Key: DRILL-8239
>                 URL: https://issues.apache.org/jira/browse/DRILL-8239
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Execution - Data Types
>    Affects Versions: 1.20.1
>            Reporter: Charles Givre
>            Assignee: Charles Givre
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> In an effort to fully deprecate the old JsonReader, this PR converts the convert_from JSON UDF to EVF.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)