You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by vo...@apache.org on 2021/09/21 21:56:50 UTC

[drill] branch master updated: DRILL-8002: Expose clear error message for the case of errors from ElasticSearch (#2319)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new cf9acd5  DRILL-8002: Expose clear error message for the case of errors from ElasticSearch (#2319)
cf9acd5 is described below

commit cf9acd5ef6c51fdf8af94e962d944250ff495327
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Wed Sep 22 00:56:42 2021 +0300

    DRILL-8002: Expose clear error message for the case of errors from ElasticSearch (#2319)
---
 .../drill/exec/store/elasticsearch/ElasticSearchQueryTest.java | 10 ++++++++++
 .../drill/exec/store/enumerable/EnumerableRecordReader.java    |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java b/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java
index 4fa35a8..79f9344 100644
--- a/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java
+++ b/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java
@@ -595,4 +595,14 @@ public class ElasticSearchQueryTest extends ClusterTest {
             "1994-12-01 00:00:00.0", new BigDecimal("80000.00"), 0, "Graduate Degree", "S", "F", "Senior Management")
         .go();
   }
+
+  @Test
+  public void testGroupByNonExistingColumn() throws Exception {
+    try {
+      queryBuilder().sql("select distinct(full_name123) from elastic.`employee`").run();
+      fail("Query didn't fail");
+    } catch (UserRemoteException e) {
+      assertThat(e.getMessage(), containsString("EXECUTION_ERROR ERROR: Field full_name123 not defined for employee"));
+    }
+  }
 }
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/EnumerableRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/EnumerableRecordReader.java
index 66e8a24..79346f1 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/EnumerableRecordReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/EnumerableRecordReader.java
@@ -17,10 +17,12 @@
  */
 package org.apache.drill.exec.store.enumerable;
 
+import lombok.extern.slf4j.Slf4j;
 import org.apache.calcite.DataContext;
 import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
 import org.apache.calcite.schema.SchemaPlus;
 import org.apache.calcite.util.BuiltInMethod;
+import org.apache.drill.common.exceptions.DrillRuntimeException;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.exec.compile.ClassBuilder;
 import org.apache.drill.exec.exception.ClassTransformationException;
@@ -34,6 +36,7 @@ import org.apache.drill.exec.record.ColumnConverter;
 import org.apache.drill.exec.record.ColumnConverterFactory;
 import org.apache.drill.exec.record.metadata.TupleMetadata;
 import org.apache.drill.exec.record.metadata.TupleSchema;
+import org.apache.drill.shaded.guava.com.google.common.base.Throwables;
 import org.codehaus.commons.compiler.CompileException;
 
 import java.io.IOException;
@@ -48,6 +51,7 @@ import java.util.stream.StreamSupport;
  * {@link ManagedReader} implementation that compiles and executes specified code,
  * calls the method on it for obtaining the values, and reads the results using column converters.
  */
+@Slf4j
 public class EnumerableRecordReader implements ManagedReader<SchemaNegotiator> {
 
   private static final String CLASS_NAME = "Baz";
@@ -99,7 +103,9 @@ public class EnumerableRecordReader implements ManagedReader<SchemaNegotiator> {
             .iterator();
       }
     } catch (CompileException | IOException | ClassTransformationException | ReflectiveOperationException e) {
-      throw new RuntimeException("Exception happened when executing generated code", e.getCause());
+      logger.error("Exception happened when executing generated code", e);
+      Throwable rootCause = Throwables.getRootCause(e);
+      throw new DrillRuntimeException(rootCause.getMessage(), rootCause);
     }
   }