You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ar...@apache.org on 2018/10/19 12:52:51 UTC

[drill] branch master updated (a26d848 -> 785f59b)

This is an automated email from the ASF dual-hosted git repository.

arina pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git.


    from a26d848  DRILL-6084: Show Drill functions in WebUI for autocomplete
     new f5bdbf3  DRILL-6785: DataClient is using RootAllocator in the bootstrap instead of dataPool
     new 91962d3  DRILL-6793: FragmentExecutor cannot send its final state for the case when RootExec root wasn't initialized
     new 785f59b  DRILL-6795: Upgrade Janino compiler from 2.7.6 to 3.0.10

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../store/mapr/db/json/MaprDBJsonRecordReader.java |   2 +-
 .../store/hive/readers/HiveAbstractReader.java     |   2 +-
 exec/java-exec/pom.xml                             |   8 ++
 .../apache/drill/exec/expr/fn/ImportGrabber.java   |  47 ++++----
 .../drill/exec/expr/fn/MethodGrabbingVisitor.java  |  68 ++++++------
 .../drill/exec/expr/fn/ModifiedUnparseVisitor.java | 120 ---------------------
 .../drill/exec/expr/fn/ModifiedUnparser.java       | 110 +++++++++++++++++++
 .../drill/exec/physical/impl/BaseRootExec.java     |   4 +
 .../org/apache/drill/exec/rpc/data/DataClient.java |   2 +-
 .../drill/exec/store/avro/AvroRecordReader.java    |   6 +-
 .../sequencefile/SequenceFileRecordReader.java     |   2 +-
 .../drill/exec/work/fragment/FragmentExecutor.java |   2 +-
 pom.xml                                            |   7 +-
 13 files changed, 190 insertions(+), 190 deletions(-)
 delete mode 100644 exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparseVisitor.java
 create mode 100644 exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparser.java


[drill] 02/03: DRILL-6793: FragmentExecutor cannot send its final state for the case when RootExec root wasn't initialized

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

arina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 91962d3dd38119ad04fa6b646a4980fd77e828d8
Author: Bohdan Kazydub <bo...@gmail.com>
AuthorDate: Tue Oct 16 17:11:36 2018 +0300

    DRILL-6793: FragmentExecutor cannot send its final state for the case when RootExec root wasn't initialized
    
    closes #1506
---
 .../drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java       | 2 +-
 .../apache/drill/exec/store/hive/readers/HiveAbstractReader.java    | 2 +-
 .../main/java/org/apache/drill/exec/physical/impl/BaseRootExec.java | 4 ++++
 .../java/org/apache/drill/exec/store/avro/AvroRecordReader.java     | 6 ++++--
 .../exec/store/easy/sequencefile/SequenceFileRecordReader.java      | 2 +-
 .../java/org/apache/drill/exec/work/fragment/FragmentExecutor.java  | 2 +-
 6 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java
index b68f574..628a986 100644
--- a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java
+++ b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java
@@ -531,7 +531,7 @@ public class MaprDBJsonRecordReader extends AbstractRecordReader {
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("MaprDBJsonRecordReader[Table=")
-        .append(table.getPath());
+        .append(table != null ? table.getPath() : null);
     if (reader != null) {
       sb.append(", Document ID=")
           .append(IdCodec.asString(reader.getId()));
diff --git a/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/readers/HiveAbstractReader.java b/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/readers/HiveAbstractReader.java
index 5ed6c3b..cc774d9 100644
--- a/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/readers/HiveAbstractReader.java
+++ b/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/readers/HiveAbstractReader.java
@@ -429,7 +429,7 @@ public abstract class HiveAbstractReader extends AbstractRecordReader {
         position = reader.getPos();
       }
     } catch (IOException e) {
-      logger.trace("Unable to obtain reader position: " + e.getMessage());
+      logger.trace("Unable to obtain reader position.", e);
     }
     return getClass().getSimpleName() + "[Database=" + table.getDbName()
         + ", Table=" + table.getTableName()
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BaseRootExec.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BaseRootExec.java
index 9142a2a..95a1235 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BaseRootExec.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BaseRootExec.java
@@ -126,6 +126,10 @@ public abstract class BaseRootExec implements RootExec {
 
   @Override
   public void dumpBatches() {
+    if (operators == null) {
+      return;
+    }
+
     final int numberOfBatchesToDump = 2;
     logger.error("Batch dump started: dumping last {} failed batches", numberOfBatchesToDump);
     // As batches are stored in a 'flat' List there is a need to filter out the failed batch
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java
index 7668130..1d7226a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java
@@ -403,9 +403,11 @@ public class AvroRecordReader extends AbstractRecordReader {
   public String toString() {
     long currentPosition = -1L;
     try {
-      currentPosition = reader.tell();
+      if (reader != null) {
+        currentPosition = reader.tell();
+      }
     } catch (IOException e) {
-      logger.trace("Unable to obtain reader position: " + e.getMessage());
+      logger.trace("Unable to obtain reader position.", e);
     }
     return "AvroRecordReader[File=" + hadoop
         + ", Position=" + currentPosition
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java
index 549df82..7f9b993 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java
@@ -172,7 +172,7 @@ public class SequenceFileRecordReader extends AbstractRecordReader {
         position = reader.getPos();
       }
     } catch (IOException e) {
-      logger.trace("Unable to obtain reader position: " + e.getMessage());
+      logger.trace("Unable to obtain reader position.", e);
     }
     return "SequenceFileRecordReader[File=" + split.getPath()
         + ", Position=" + position
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
index a9e9e62..e374c01 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
@@ -207,7 +207,7 @@ public class FragmentExecutor implements Runnable {
   }
 
   private void cleanup(FragmentState state) {
-    if (fragmentState.get() == FragmentState.FAILED) {
+    if (root != null && fragmentState.get() == FragmentState.FAILED) {
       root.dumpBatches();
     }
 


[drill] 01/03: DRILL-6785: DataClient is using RootAllocator in the bootstrap instead of dataPool

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

arina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit f5bdbf344bfbd069fd3f1143b23624457ace19a9
Author: Sorabh Hamirwasia <sh...@maprtech.com>
AuthorDate: Mon Oct 8 11:28:27 2018 -0700

    DRILL-6785: DataClient is using RootAllocator in the bootstrap instead of dataPool
    
    closes #1502
---
 .../src/main/java/org/apache/drill/exec/rpc/data/DataClient.java        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClient.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClient.java
index f222941..da6e176 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClient.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClient.java
@@ -50,7 +50,7 @@ public class DataClient extends BasicClient<RpcType, DataClientConnection, BitCl
     super(
         DataRpcConfig.getMapping(config.getBootstrapContext().getConfig(),
             config.getBootstrapContext().getExecutor()),
-        config.getBootstrapContext().getAllocator().getAsByteBufAllocator(),
+        config.getAllocator().getAsByteBufAllocator(),
         config.getBootstrapContext().getBitClientLoopGroup(),
         RpcType.HANDSHAKE,
         BitServerHandshake.class,


[drill] 03/03: DRILL-6795: Upgrade Janino compiler from 2.7.6 to 3.0.10

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

arina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 785f59bf03e402c117df0f5e0a9f1c6ef6863966
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Sat Oct 13 16:13:36 2018 +0300

    DRILL-6795: Upgrade Janino compiler from 2.7.6 to 3.0.10
    
    closes #1503
---
 exec/java-exec/pom.xml                             |   8 ++
 .../apache/drill/exec/expr/fn/ImportGrabber.java   |  47 ++++----
 .../drill/exec/expr/fn/MethodGrabbingVisitor.java  |  68 ++++++------
 .../drill/exec/expr/fn/ModifiedUnparseVisitor.java | 120 ---------------------
 .../drill/exec/expr/fn/ModifiedUnparser.java       | 110 +++++++++++++++++++
 pom.xml                                            |   7 +-
 6 files changed, 177 insertions(+), 183 deletions(-)

diff --git a/exec/java-exec/pom.xml b/exec/java-exec/pom.xml
index 5b00a8c..43897ef 100644
--- a/exec/java-exec/pom.xml
+++ b/exec/java-exec/pom.xml
@@ -350,6 +350,14 @@
       <version>2.9</version>
     </dependency>
     <dependency>
+      <groupId>org.codehaus.janino</groupId>
+      <artifactId>janino</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.janino</groupId>
+      <artifactId>commons-compiler</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-common</artifactId>
       <exclusions>
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ImportGrabber.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ImportGrabber.java
index e75d20b..3e67ebf 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ImportGrabber.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ImportGrabber.java
@@ -17,6 +17,7 @@
  */
 package org.apache.drill.exec.expr.fn;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.codehaus.janino.Java;
@@ -24,20 +25,32 @@ import org.codehaus.janino.Java.CompilationUnit.SingleStaticImportDeclaration;
 import org.codehaus.janino.Java.CompilationUnit.SingleTypeImportDeclaration;
 import org.codehaus.janino.Java.CompilationUnit.StaticImportOnDemandDeclaration;
 import org.codehaus.janino.Java.CompilationUnit.TypeImportOnDemandDeclaration;
-import org.codehaus.janino.util.Traverser;
-
-import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
-
+import org.codehaus.janino.util.AbstractTraverser;
 
 public class ImportGrabber {
 
-  private final List<String> imports = Lists.newArrayList();
-  private final ImportFinder finder = new ImportFinder();
+  private final List<String> imports = new ArrayList<>();
+  private final ImportFinder importFinder = new ImportFinder();
 
   private ImportGrabber() {
   }
 
-  public class ImportFinder extends Traverser {
+  /**
+   * Creates list of imports that are present in compilation unit.
+   * For example:
+   * [import io.netty.buffer.DrillBuf;, import org.apache.drill.exec.expr.DrillSimpleFunc;]
+   *
+   * @param compilationUnit compilation unit
+   * @return list of imports
+   */
+  public static List<String> getImports(Java.CompilationUnit compilationUnit) {
+    ImportGrabber visitor = new ImportGrabber();
+    compilationUnit.importDeclarations.forEach(visitor.importFinder::visitImportDeclaration);
+
+    return visitor.imports;
+  }
+
+  public class ImportFinder extends AbstractTraverser<RuntimeException> {
 
     @Override
     public void traverseSingleTypeImportDeclaration(SingleTypeImportDeclaration stid) {
@@ -58,26 +71,6 @@ public class ImportGrabber {
     public void traverseStaticImportOnDemandDeclaration(StaticImportOnDemandDeclaration siodd) {
       imports.add(siodd.toString());
     }
-
-
-  }
-
-  /**
-   * Creates list of imports that are present in compilation unit.
-   * For example:
-   * [import io.netty.buffer.DrillBuf;, import org.apache.drill.exec.expr.DrillSimpleFunc;]
-   *
-   * @param compilationUnit compilation unit
-   * @return list of imports
-   */
-  public static List<String> getImports(Java.CompilationUnit compilationUnit){
-    final ImportGrabber visitor = new ImportGrabber();
-
-    for (Java.CompilationUnit.ImportDeclaration importDeclaration : compilationUnit.importDeclarations) {
-      importDeclaration.accept(visitor.finder.comprehensiveVisitor());
-    }
-
-    return visitor.imports;
   }
 
 }
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/MethodGrabbingVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/MethodGrabbingVisitor.java
index 47ca9b2..782e1e2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/MethodGrabbingVisitor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/MethodGrabbingVisitor.java
@@ -18,62 +18,60 @@
 package org.apache.drill.exec.expr.fn;
 
 import java.io.StringWriter;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.codehaus.janino.Java;
-import org.codehaus.janino.Java.ClassDeclaration;
+import org.codehaus.janino.Java.AbstractClassDeclaration;
 import org.codehaus.janino.Java.MethodDeclarator;
-import org.codehaus.janino.util.Traverser;
+import org.codehaus.janino.util.AbstractTraverser;
 
-import org.apache.drill.shaded.guava.com.google.common.collect.Maps;
+public class MethodGrabbingVisitor {
 
-
-public class MethodGrabbingVisitor{
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MethodGrabbingVisitor.class);
-
-  private Class<?> c;
-  private Map<String, String> methods = Maps.newHashMap();
-  private ClassFinder classFinder = new ClassFinder();
+  private final Class<?> clazz;
+  private final Map<String, String> methods = new HashMap<>();
+  private final ClassFinder classFinder = new ClassFinder();
   private boolean captureMethods = false;
 
-  private MethodGrabbingVisitor(Class<?> c) {
-    super();
-    this.c = c;
+  private MethodGrabbingVisitor(Class<?> clazz) {
+    this.clazz = clazz;
+  }
+
+  /**
+   * Creates a map with all method names and their modified bodies
+   * from specified {@link Java.CompilationUnit}.
+   *
+   * @param compilationUnit the source of the methods to collect
+   * @param clazz           type of the class to handle
+   * @return a map with all method names and their modified bodies.
+   */
+  public static Map<String, String> getMethods(Java.CompilationUnit compilationUnit, Class<?> clazz) {
+    MethodGrabbingVisitor visitor = new MethodGrabbingVisitor(clazz);
+    visitor.classFinder.visitTypeDeclaration(compilationUnit.getPackageMemberTypeDeclarations()[0]);
+    return visitor.methods;
   }
 
-  public class ClassFinder extends Traverser{
+  public class ClassFinder extends AbstractTraverser<RuntimeException> {
 
     @Override
-    public void traverseClassDeclaration(ClassDeclaration cd) {
-//      logger.debug("Traversing: {}", cd.getClassName());
+    public void traverseClassDeclaration(AbstractClassDeclaration classDeclaration) {
       boolean prevCapture = captureMethods;
-      captureMethods = c.getName().equals(cd.getClassName());
-      super.traverseClassDeclaration(cd);
+      captureMethods = clazz.getName().equals(classDeclaration.getClassName());
+      super.traverseClassDeclaration(classDeclaration);
       captureMethods = prevCapture;
     }
 
     @Override
-    public void traverseMethodDeclarator(MethodDeclarator md) {
-//      logger.debug(c.getName() + ": Found {}, include {}", md.name, captureMethods);
-
-      if(captureMethods){
+    public void traverseMethodDeclarator(MethodDeclarator methodDeclarator) {
+      if (captureMethods) {
         StringWriter writer = new StringWriter();
-        ModifiedUnparseVisitor v = new ModifiedUnparseVisitor(writer);
-//        UnparseVisitor v = new UnparseVisitor(writer);
-
-        md.accept(v);
-        v.close();
+        ModifiedUnparser unparser = new ModifiedUnparser(writer);
+        unparser.visitMethodDeclarator(methodDeclarator);
+        unparser.close();
         writer.flush();
-        methods.put(md.name, writer.getBuffer().toString());
+        methods.put(methodDeclarator.name, writer.getBuffer().toString());
       }
     }
   }
 
-
-  public static Map<String, String> getMethods(Java.CompilationUnit cu, Class<?> c){
-    MethodGrabbingVisitor visitor = new MethodGrabbingVisitor(c);
-    cu.getPackageMemberTypeDeclarations()[0].accept(visitor.classFinder.comprehensiveVisitor());
-    return visitor.methods;
-  }
-
 }
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparseVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparseVisitor.java
deleted file mode 100644
index fe83490..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparseVisitor.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.exec.expr.fn;
-
-import java.io.Writer;
-import java.util.List;
-
-import org.codehaus.janino.Java;
-import org.codehaus.janino.UnparseVisitor;
-import org.codehaus.janino.util.AutoIndentWriter;
-
-/**
- * This is a modified version of {@link UnparseVisitor} so that we can avoid
- * rendering few things. Based on janino version 2.7.4.
- */
-public class ModifiedUnparseVisitor extends UnparseVisitor {
-
-  private String returnLabel;
-
-  /**
-   * Testing of parsing/unparsing.
-   * <p>
-   * Reads compilation units from the files named on the command line
-   * and unparses them to {@link System#out}.
-   */
-  public static void main(String[] args) throws Exception {
-    UnparseVisitor.main(args);
-  }
-
-  /**
-   * Unparse the given {@link org.codehaus.janino.Java.CompilationUnit} to the given {@link java.io.Writer}.
-   */
-  public static void unparse(Java.CompilationUnit cu, Writer w) {
-    UnparseVisitor.unparse(cu, w);
-  }
-
-  public ModifiedUnparseVisitor(Writer w) {
-    super(w);
-  }
-
-  @Override
-  public void visitMethodDeclarator(Java.MethodDeclarator md) {
-    if (md.optionalStatements == null) {
-      this.pw.print(';');
-    } else
-      if (md.optionalStatements.isEmpty()) {
-        this.pw.print(" {}");
-      } else {
-        this.pw.println(' ');
-        // Add labels to handle return statements within function templates
-        String[] fQCN = md.getDeclaringType().getClassName().split("\\.");
-        returnLabel = fQCN[fQCN.length - 1] + "_" + md.name;
-        this.pw.println(returnLabel + ": {");
-        this.pw.print(AutoIndentWriter.INDENT);
-        this.unparseStatements(md.optionalStatements);
-        this.pw.print(AutoIndentWriter.UNINDENT);
-        this.pw.println("}");
-        this.pw.print(' ');
-      }
-  }
-
-  @Override
-  public void visitReturnStatement(Java.ReturnStatement rs) {
-    this.pw.print("break " + returnLabel);
-    if (rs.optionalReturnValue != null) {
-      this.pw.print(' ');
-      this.unparse(rs.optionalReturnValue);
-    }
-    this.pw.print(';');
-  }
-
-  /*
-   * The following helper methods are copied from the parent class since they
-   * are declared private in the parent class and can not be used in the child
-   * class (this).
-   */
-
-  private void unparseStatements(List<? extends Java.BlockStatement> statements) {
-    int state = -1;
-    for (Java.BlockStatement bs : statements) {
-      int x  = (
-          bs instanceof Java.Block                             ? 1 :
-          bs instanceof Java.LocalClassDeclarationStatement    ? 2 :
-          bs instanceof Java.LocalVariableDeclarationStatement ? 3 :
-          bs instanceof Java.SynchronizedStatement             ? 4 :
-          99
-      );
-      if (state != -1 && state != x) {
-        this.pw.println(AutoIndentWriter.CLEAR_TABULATORS);
-      }
-      state = x;
-
-      this.unparseBlockStatement(bs);
-      this.pw.println();
-    }
-  }
-
-  private void unparseBlockStatement(Java.BlockStatement blockStatement) {
-    blockStatement.accept(this);
-  }
-
-  private void unparse(Java.Atom operand) {
-    operand.accept(this);
-  }
-}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparser.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparser.java
new file mode 100644
index 0000000..e7b2244
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/ModifiedUnparser.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.expr.fn;
+
+import java.io.Writer;
+import java.util.List;
+
+import org.codehaus.janino.Java;
+import org.codehaus.janino.Unparser;
+import org.codehaus.janino.util.AutoIndentWriter;
+
+/**
+ * This is a modified version of {@link Unparser} so that we can avoid
+ * rendering few things.
+ */
+public class ModifiedUnparser extends Unparser {
+
+  private String returnLabel;
+
+  public ModifiedUnparser(Writer writer) {
+    super(writer);
+  }
+
+  @Override
+  public void unparseBlockStatement(Java.BlockStatement blockStatement) {
+    // Unparser uses anonymous classes for visiting statements,
+    // therefore added this check for customizing of handling ReturnStatement.
+    if (blockStatement instanceof Java.ReturnStatement) {
+      visitReturnStatement((Java.ReturnStatement) blockStatement);
+    } else {
+      super.unparseBlockStatement(blockStatement);
+    }
+  }
+
+  /**
+   * Parses specified {@link Java.MethodDeclarator}, wraps its content
+   * with replaced {@code return} statements by {@code break} ones into the
+   * block with label and stores it into {@link java.io.PrintWriter}.
+   *
+   * @param methodDeclarator method to parse
+   */
+  public void visitMethodDeclarator(Java.MethodDeclarator methodDeclarator) {
+    if (methodDeclarator.optionalStatements == null) {
+      pw.print(';');
+    } else if (methodDeclarator.optionalStatements.isEmpty()) {
+      pw.print(" {}");
+    } else {
+      pw.println(' ');
+      // Add labels to handle return statements within function templates
+      String[] fQCN = methodDeclarator.getDeclaringType().getClassName().split("\\.");
+      returnLabel = fQCN[fQCN.length - 1] + "_" + methodDeclarator.name;
+      pw.print(returnLabel);
+      pw.println(": {");
+      pw.print(AutoIndentWriter.INDENT);
+      unparseStatements(methodDeclarator.optionalStatements);
+      pw.print(AutoIndentWriter.UNINDENT);
+      pw.println("}");
+      pw.print(' ');
+    }
+  }
+
+  private void visitReturnStatement(Java.ReturnStatement returnStatement) {
+    pw.print("break ");
+    pw.print(returnLabel);
+    if (returnStatement.optionalReturnValue != null) {
+      pw.print(' ');
+      unparseAtom(returnStatement.optionalReturnValue);
+    }
+    pw.print(';');
+  }
+
+  /**
+   * The following helper method is copied from the parent class since it
+   * is declared as private in the parent class and can not be used in the child
+   * class (this).
+   */
+  private void unparseStatements(List<? extends Java.BlockStatement> statements) {
+    int state = -1;
+    for (Java.BlockStatement bs : statements) {
+      int x = (
+        bs instanceof Java.Block ? 1 :
+          bs instanceof Java.LocalClassDeclarationStatement ? 2 :
+            bs instanceof Java.LocalVariableDeclarationStatement ? 3 :
+              bs instanceof Java.SynchronizedStatement ? 4 : 99
+      );
+      if (state != -1 && state != x) {
+        pw.println(AutoIndentWriter.CLEAR_TABULATORS);
+      }
+      state = x;
+
+      unparseBlockStatement(bs);
+      pw.println();
+    }
+  }
+}
diff --git a/pom.xml b/pom.xml
index 3a2d21e..dbd8caf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
     <parquet.version>1.10.0</parquet.version>
     <calcite.version>1.17.0-drill-r1</calcite.version>
     <avatica.version>1.12.0</avatica.version>
-    <janino.version>2.7.6</janino.version>
+    <janino.version>3.0.10</janino.version>
     <sqlline.version>1.5.0</sqlline.version>
     <jackson.version>2.9.5</jackson.version>
     <jackson.databind.version>2.9.5</jackson.databind.version>
@@ -1367,6 +1367,11 @@
         <version>${janino.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.codehaus.janino</groupId>
+        <artifactId>commons-compiler</artifactId>
+        <version>${janino.version}</version>
+      </dependency>
+      <dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-annotations</artifactId>
         <version>${jackson.version}</version>