drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject [2/3] drill git commit: DRILL-1780: check if result set is empty before accessing; show a neat message to the user when resultset is empty; minor refactorings to DrillRestServer
Date Mon, 01 Dec 2014 03:05:20 GMT
DRILL-1780: check if result set is empty before accessing;
 show a neat message to the user when resultset is empty; minor refactorings
 to DrillRestServer


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/4af4fcd4
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/4af4fcd4
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/4af4fcd4

Branch: refs/heads/merge_14_11_30_1
Commit: 4af4fcd4667dfbe3ad133b5615726fbbbbae84dd
Parents: 6483eb4
Author: Hanifi Gunes <hgunes@maprtech.com>
Authored: Sun Nov 30 16:23:07 2014 -0800
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Sun Nov 30 16:23:07 2014 -0800

----------------------------------------------------------------------
 .../drill/exec/server/rest/DrillRestServer.java | 20 +++++++++-----------
 .../drill/exec/server/rest/QueryResources.java  | 10 +++++++++-
 .../src/main/resources/rest/query/result.ftl    |  8 ++++++--
 3 files changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/4af4fcd4/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
index cdbaaaf..e8cb4ba 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
@@ -45,22 +45,20 @@ public class DrillRestServer extends ResourceConfig {
     register(MetricsResources.class);
     register(ThreadsResources.class);
     register(FreemarkerMvcFeature.class);
-    property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
     register(MultiPartFeature.class);
+    property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
 
-    register_jackson : {
 
-      //disable moxy so it doesn't conflict with jackson.
-      final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
-      property(disableMoxy, true);
+    //disable moxy so it doesn't conflict with jackson.
+    final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
+    property(disableMoxy, true);
 
-      register(JsonParseExceptionMapper.class);
-      register(JsonMappingExceptionMapper.class);
+    register(JsonParseExceptionMapper.class);
+    register(JsonMappingExceptionMapper.class);
 
-      JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
-      provider.setMapper(workManager.getContext().getConfig().getMapper());
-      register(provider);
-    }
+    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
+    provider.setMapper(workManager.getContext().getConfig().getMapper());
+    register(provider);
 
     register(new AbstractBinder() {
       @Override

http://git-wip-us.apache.org/repos/asf/drill/blob/4af4fcd4/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
index ba59d8f..f8998ed 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
@@ -30,6 +30,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
+import com.google.common.collect.Lists;
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.exec.coord.ClusterCoordinator;
 import org.apache.drill.exec.memory.BufferAllocator;
@@ -68,7 +69,12 @@ public class QueryResources {
   public Viewable submitQuery(@FormParam("query") String query, @FormParam("queryType") String
queryType) throws Exception {
     List<Map<String, Object>> result = submitQueryJSON(new QueryWrapper(query,
queryType));
 
-    List<String> columnNames = new ArrayList<>(result.get(0).keySet());
+    List<String> columnNames;
+    if (result.isEmpty()) {
+      columnNames = Lists.newArrayList();
+    } else {
+      columnNames = Lists.newArrayList(result.get(0).keySet());
+    }
     List<List<Object>> records = new ArrayList<>();
 
     if(!isEmptyResult(result)) {
@@ -105,6 +111,8 @@ public class QueryResources {
       this.records = records;
     }
 
+    public boolean isEmpty() { return getColumnNames().isEmpty(); }
+
     public List<String> getColumnNames() {
       return columnNames;
     }

http://git-wip-us.apache.org/repos/asf/drill/blob/4af4fcd4/exec/java-exec/src/main/resources/rest/query/result.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/query/result.ftl b/exec/java-exec/src/main/resources/rest/query/result.ftl
index e615bc5..b69bd6d 100644
--- a/exec/java-exec/src/main/resources/rest/query/result.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/result.ftl
@@ -25,7 +25,11 @@
   <a href="/queries">back</a><br/>
   <div class="page-header">
   </div>
-  <div>
+  <#if model.isEmpty()>
+    <div class="jumbotron">
+      <p class="lead">No result found.</p>
+    </div>
+  <#else>
     <table id="result" class="table table-striped table-bordered table-condensed" style="table-layout:
auto; width=100%;">
       <thead>
         <tr>
@@ -44,7 +48,7 @@
       </#list>
       </tbody>
     </table>
-  </div>
+  </#if>
   <script charset="utf-8">
     $(document).ready(function() {
       $('#result').dataTable( {


Mime
View raw message