You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by hm...@apache.org on 2019/01/07 21:47:54 UTC

[drill] branch master updated (7a25d9d -> f7ed58f)

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

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


    from 7a25d9d  DRILL-540: Allow querying hive views in Drill
     new 814e9f0  DRILL-6946: Implement java.sql.Connection setSchema and getSchema methods in DrillConnectionImpl closes #1596
     new cd3c394  DRILL-6933: Fix ctrl+enter when Impersonation is disabled
     new 5c90032  DRILL-6939: Indicate when a query is submitted and is in progress
     new feaf5b2  DRILL-6050: Provide a limit to number of rows fetched for a query in UI
     new f7ed58f  DRILL-6941: Incorrect EARLY_LIMIT0_OPT_KEY description

The 5 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:
 contrib/native/client/src/protobuf/User.pb.cc      | 196 ++++++++----
 contrib/native/client/src/protobuf/User.pb.h       |  87 +++++-
 .../java/org/apache/drill/exec/ExecConstants.java  |   6 +-
 .../drill/exec/server/rest/DrillRestServer.java    |   2 +-
 .../drill/exec/server/rest/QueryResources.java     |  60 +++-
 .../apache/drill/exec/server/rest/WebServer.java   |   4 +-
 .../exec/server/rest/profile/ProfileWrapper.java   |   2 +-
 .../exec/work/metadata/ServerMetaProvider.java     |   3 +-
 .../java-exec/src/main/resources/drill-module.conf |   7 +
 .../src/main/resources/rest/profile/profile.ftl    |  30 +-
 .../src/main/resources/rest/query/query.ftl        |  17 +-
 .../src/main/resources/rest/query/result.ftl       |   2 +-
 .../src/main/resources/rest/runningQuery.ftl       |  44 +++
 .../src/main/resources/rest/static/img/loader.gif  | Bin 0 -> 26758 bytes
 .../resources/rest/static/js/querySubmission.js    |  77 ++++-
 .../exec/work/metadata/TestServerMetaProvider.java |  43 ++-
 .../drill/jdbc/impl/DrillConnectionImpl.java       |  31 ++
 .../org/apache/drill/jdbc/ConnectionInfoTest.java  |  85 ++++--
 .../apache/drill/exec/proto/SchemaUserProtos.java  |   7 +
 .../org/apache/drill/exec/proto/UserProtos.java    | 336 +++++++++++++++++----
 .../apache/drill/exec/proto/beans/ServerMeta.java  |  22 ++
 protocol/src/main/protobuf/User.proto              |   2 +
 22 files changed, 845 insertions(+), 218 deletions(-)
 create mode 100644 exec/java-exec/src/main/resources/rest/runningQuery.ftl
 create mode 100644 exec/java-exec/src/main/resources/rest/static/img/loader.gif


[drill] 05/05: DRILL-6941: Incorrect EARLY_LIMIT0_OPT_KEY description

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

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

commit f7ed58fc97bbf0c684891e07bf5132e055efb1d9
Author: Kunal Khatua <kk...@maprtech.com>
AuthorDate: Fri Jan 4 16:35:46 2019 -0800

    DRILL-6941: Incorrect EARLY_LIMIT0_OPT_KEY description
    
    Description was accidentally duplicated from `planner.parser.quoting_identifiers`
    closes #1597
---
 exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
index 6285068..a0376a4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
@@ -567,7 +567,7 @@ public final class ExecConstants {
 
   public static final String EARLY_LIMIT0_OPT_KEY = "planner.enable_limit0_optimization";
   public static final BooleanValidator EARLY_LIMIT0_OPT = new BooleanValidator(EARLY_LIMIT0_OPT_KEY,
-      new OptionDescription("Sets the type of identifier quotes for the SQL parser. Default is backticks ('`'). The SQL parser accepts double quotes ('\"') and square brackets ('['). (Drill 1.11+)"));
+      new OptionDescription("Enables the query planner to determine data types returned by a query during the planning phase before scanning data. Default is true. (Drill 1.9+)"));
 
   public static final String LATE_LIMIT0_OPT_KEY = "planner.enable_limit0_on_scan";
   public static final BooleanValidator LATE_LIMIT0_OPT = new BooleanValidator(LATE_LIMIT0_OPT_KEY,


[drill] 02/05: DRILL-6933: Fix ctrl+enter when Impersonation is disabled

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

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

commit cd3c3948bd3604e74897a52bcac527e624c1950b
Author: Kunal Khatua <kk...@maprtech.com>
AuthorDate: Thu Jan 3 10:25:38 2019 -0800

    DRILL-6933: Fix ctrl+enter when Impersonation is disabled
    
    Without impersonation, the key combination did not work because a conditional block of the FTLs skipped the Javascript functions required for submitting with the key combination.
    This commit fixes that by unifying the functions that are common to both approaches of submitting a query (with and without impersoination)
    [Update] Changes made to isOnlyImpersonationEnabled method and onlyImpersonationEnabled variable
    [Update] userName is a global var in the script
    closes #1591
---
 .../drill/exec/server/rest/DrillRestServer.java    |  2 +-
 .../drill/exec/server/rest/QueryResources.java     |  2 +-
 .../apache/drill/exec/server/rest/WebServer.java   |  4 ++--
 .../exec/server/rest/profile/ProfileWrapper.java   |  2 +-
 .../src/main/resources/rest/profile/profile.ftl    | 27 +++++++++++-----------
 .../src/main/resources/rest/query/query.ftl        | 11 ++++-----
 .../resources/rest/static/js/querySubmission.js    | 14 +++++++++--
 7 files changed, 35 insertions(+), 27 deletions(-)

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 148d239..da8ccdc 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
@@ -313,7 +313,7 @@ public class DrillRestServer extends ResourceConfig {
      * @return session user principal
      */
     private Principal createSessionUserPrincipal(DrillConfig config, HttpServletRequest request) {
-      if (WebServer.isImpersonationOnlyEnabled(config)) {
+      if (WebServer.isOnlyImpersonationEnabled(config)) {
         final String userName = request.getHeader("User-Name");
         if (!Strings.isNullOrEmpty(userName)) {
           return new DrillUserPrincipal(userName, true);
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 e585cf9..5233767 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
@@ -59,7 +59,7 @@ public class QueryResources {
         "/rest/query/query.ftl",
         sc,
         // if impersonation is enabled without authentication, will provide mechanism to add user name to request header from Web UI
-        WebServer.isImpersonationOnlyEnabled(work.getContext().getConfig()));
+        WebServer.isOnlyImpersonationEnabled(work.getContext().getConfig()));
   }
 
   @POST
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
index c02acd2..689b06b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
@@ -164,7 +164,7 @@ public class WebServer implements AutoCloseable {
    * @param config Drill configuration
    * @return true if impersonation without authentication is enabled, false otherwise
    */
-  public static boolean isImpersonationOnlyEnabled(DrillConfig config) {
+  public static boolean isOnlyImpersonationEnabled(DrillConfig config) {
     return !config.getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED)
         && config.getBoolean(ExecConstants.IMPERSONATION_ENABLED);
   }
@@ -259,7 +259,7 @@ public class WebServer implements AutoCloseable {
       servletContextHandler.setSessionHandler(createSessionHandler(servletContextHandler.getSecurityHandler()));
     }
 
-    if (isImpersonationOnlyEnabled(workManager.getContext().getConfig())) {
+    if (isOnlyImpersonationEnabled(workManager.getContext().getConfig())) {
       for (String path : new String[]{"/query", "/query.json"}) {
         servletContextHandler.addFilter(UserNameFilter.class, path, EnumSet.of(DispatcherType.REQUEST));
       }
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java
index 7e72556..bf07114 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java
@@ -130,7 +130,7 @@ public class ProfileWrapper {
     }
     this.options = options;
 
-    this.onlyImpersonationEnabled = WebServer.isImpersonationOnlyEnabled(drillConfig);
+    this.onlyImpersonationEnabled = WebServer.isOnlyImpersonationEnabled(drillConfig);
     this.noProgressWarningThreshold = String.valueOf(drillConfig.getInt(ExecConstants.PROFILE_WARNING_PROGRESS_THRESHOLD));
   }
 
diff --git a/exec/java-exec/src/main/resources/rest/profile/profile.ftl b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
index 6b4e732..ab245c7 100644
--- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
@@ -23,18 +23,16 @@
 <script src="/static/js/dagre-d3.min.js"></script>
 <script src="/static/js/graph.js"></script>
 <script src="/static/js/jquery.dataTables-1.10.16.min.js"></script>
-<#if model.isOnlyImpersonationEnabled()>
-    <script src="/static/js/jquery.form.js"></script>
-    <script src="/static/js/querySubmission.js"></script>
-</#if>
-  <!-- Ace Libraries for Syntax Formatting -->
-  <script src="/static/js/ace-code-editor/ace.js" type="text/javascript" charset="utf-8"></script>
-  <!-- Disabled in favour of dynamic: script src="/static/js/ace-code-editor/mode-sql.js" type="text/javascript" charset="utf-8" -->
-  <script src="/dynamic/mode-sql.js" type="text/javascript" charset="utf-8"></script>
-  <script src="/static/js/ace-code-editor/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
-  <script src="/static/js/ace-code-editor/theme-sqlserver.js" type="text/javascript" charset="utf-8"></script>
-  <script src="/static/js/ace-code-editor/snippets/sql.js" type="text/javascript" charset="utf-8"></script>
-  <script src="/static/js/ace-code-editor/mode-snippets.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/jquery.form.js"></script>
+<script src="/static/js/querySubmission.js"></script>
+<!-- Ace Libraries for Syntax Formatting -->
+<script src="/static/js/ace-code-editor/ace.js" type="text/javascript" charset="utf-8"></script>
+<!-- Disabled in favour of dynamic: script src="/static/js/ace-code-editor/mode-sql.js" type="text/javascript" charset="utf-8" -->
+<script src="/dynamic/mode-sql.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/ace-code-editor/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/ace-code-editor/theme-sqlserver.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/ace-code-editor/snippets/sql.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/ace-code-editor/mode-snippets.js" type="text/javascript" charset="utf-8"></script>
 
 <script>
     var globalconfig = {
@@ -176,7 +174,7 @@ table.sortable thead .sorting_desc { background-image: url("/static/img/black-de
               </label>
             </div>
             </div>
-            <button class="btn btn-default" type=<#if model.isOnlyImpersonationEnabled()>"button" onclick="doSubmitQueryWithUserName()"<#else>"submit"</#if>>
+            <button class="btn btn-default" type="button" onclick="<#if model.isOnlyImpersonationEnabled()>doSubmitQueryWithUserName()<#else>submitQuery()</#if>">
             Re-run query
             </button>
           </form>
@@ -573,7 +571,8 @@ table.sortable thead .sorting_desc { background-image: url("/static/img/black-de
     document.getElementById('queryForm')
             .addEventListener('keydown', function(e) {
       if (!(e.keyCode == 13 && (e.metaKey || e.ctrlKey))) return;
-      if (e.target.form) doSubmitQueryWithUserName();
+      if (e.target.form) 
+        <#if model.isOnlyImpersonationEnabled()>doSubmitQueryWithUserName()<#else>submitQuery()</#if>;
     });
     </script>
 
diff --git a/exec/java-exec/src/main/resources/rest/query/query.ftl b/exec/java-exec/src/main/resources/rest/query/query.ftl
index fd3e8bd..3477f94 100644
--- a/exec/java-exec/src/main/resources/rest/query/query.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/query.ftl
@@ -19,10 +19,8 @@
 -->
 <#include "*/generic.ftl">
 <#macro page_head>
-    <#if model?? && model>
-      <script src="/static/js/jquery.form.js"></script>
-      <script src="/static/js/querySubmission.js"></script>
-    </#if>
+  <script src="/static/js/jquery.form.js"></script>
+  <script src="/static/js/querySubmission.js"></script>
   <!-- Ace Libraries for Syntax Formatting -->
   <script src="/static/js/ace-code-editor/ace.js" type="text/javascript" charset="utf-8"></script>
   <!-- Disabled in favour of dynamic: script src="/static/js/ace-code-editor/mode-sql.js" type="text/javascript" charset="utf-8" -->
@@ -77,7 +75,7 @@
       <input class="form-control" type="hidden" id="query" name="query"/>
     </div>
 
-    <button class="btn btn-default" type=<#if model?? && model>"button" onclick="doSubmitQueryWithUserName()"<#else>"submit"</#if>>
+    <button class="btn btn-default" type="button" onclick="<#if model?? && model>doSubmitQueryWithUserName()<#else>submitQuery()</#if>">
       Submit
     </button>
   </form>
@@ -125,7 +123,8 @@
     document.getElementById('queryForm')
             .addEventListener('keydown', function(e) {
       if (!(e.keyCode == 13 && (e.metaKey || e.ctrlKey))) return;
-      if (e.target.form) doSubmitQueryWithUserName();
+      if (e.target.form) 
+        <#if model?? && model>doSubmitQueryWithUserName()<#else>submitQuery()</#if>;
     });
   </script>
 
diff --git a/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js b/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
index 638ddbf..d278517 100644
--- a/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
+++ b/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
@@ -10,17 +10,27 @@
  *  OF ANY KIND, either express or implied. See the License for the specific
  *  language governing permissions and limitations under the License.
  */
+var userName = null;
 
+//Submit query with username
 function doSubmitQueryWithUserName() {
-    var userName = document.getElementById("userName").value;
+    userName = document.getElementById("userName").value;
     if (!userName.trim()) {
         alert("Please fill in User Name field");
         return;
     }
+    submitQuery();
+}
+
+//Submit Query (used if impersonation is not enabled)
+function submitQuery() {
+    //Submit query
     $.ajax({
         type: "POST",
         beforeSend: function (request) {
-            request.setRequestHeader("User-Name", userName);
+            if (typeof userName !== 'undefined' && userName != null && userName.length > 0) {
+              request.setRequestHeader("User-Name", userName);
+            }
         },
         url: "/query",
         data: $("#queryForm").serializeArray(),


[drill] 04/05: DRILL-6050: Provide a limit to number of rows fetched for a query in UI

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

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

commit feaf5b24e9639669bc43b6673ab36cf403a32525
Author: Kunal Khatua <kk...@maprtech.com>
AuthorDate: Mon Jan 7 11:19:15 2019 -0800

    DRILL-6050: Provide a limit to number of rows fetched for a query in UI
    
    Currently, the WebServer side needs to process the entire set of results and stream it back to the WebClient.
    Since the WebUI does paginate results, we can load a larger set for pagination on the browser client and relieve pressure off the WebServer to host all the data (most of which will never be streamed to the browser).
    e.g. Fetching all rows from a 1Billion records table is impractical and can be capped at (say) 1K. Currently, the user has to explicitly specify LIMIT in the submitted query.
    An option is provided in the field to allow for this entry, and can be set to selected by default for the Web UI.
    The submitted query indicates that an auto-limiting wrapper was applied.
    [Update #1] Updated as per comments
    1. Limit Wrapping Unchecked by default
    2. Full List configuration of results
    [Update #2] Minor update
    [Update #3] Followup
    closes #1593
---
 .../java/org/apache/drill/exec/ExecConstants.java  |  4 ++
 .../drill/exec/server/rest/QueryResources.java     | 60 ++++++++++++++++++----
 .../java-exec/src/main/resources/drill-module.conf |  7 +++
 .../src/main/resources/rest/query/query.ftl        | 10 ++--
 .../src/main/resources/rest/query/result.ftl       |  2 +-
 .../resources/rest/static/js/querySubmission.js    | 42 +++++++++++++--
 6 files changed, 105 insertions(+), 20 deletions(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
index ceae237..6285068 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
@@ -224,6 +224,10 @@ public final class ExecConstants {
   public static final String HTTP_AUTHENTICATION_MECHANISMS = "drill.exec.http.auth.mechanisms";
   public static final String HTTP_SPNEGO_PRINCIPAL = "drill.exec.http.auth.spnego.principal";
   public static final String HTTP_SPNEGO_KEYTAB = "drill.exec.http.auth.spnego.keytab";
+  //Control Web UI Resultset
+  public static final String HTTP_WEB_CLIENT_RESULTSET_AUTOLIMIT_CHECKED = "drill.exec.http.web.client.resultset.autolimit.checked";
+  public static final String HTTP_WEB_CLIENT_RESULTSET_AUTOLIMIT_ROWS = "drill.exec.http.web.client.resultset.autolimit.rows";
+  public static final String HTTP_WEB_CLIENT_RESULTSET_ROWS_PER_PAGE_VALUES = "drill.exec.http.web.client.resultset.rowsPerPageValues";
   //Customize filters in options
   public static final String HTTP_WEB_OPTIONS_FILTERS = "drill.exec.http.web.options.filters";
   public static final String SYS_STORE_PROVIDER_CLASS = "drill.exec.sys.store.provider.class";
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 5233767..61af7c7 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
@@ -18,8 +18,11 @@
 package org.apache.drill.exec.server.rest;
 
 import org.apache.drill.shaded.guava.com.google.common.base.CharMatcher;
+import org.apache.drill.shaded.guava.com.google.common.base.Joiner;
 import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
 import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
+import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.server.rest.DrillRestServer.UserAuthEnabled;
 import org.apache.drill.exec.server.rest.auth.DrillUserPrincipal;
 import org.apache.drill.exec.server.rest.QueryWrapper.QueryResult;
@@ -36,6 +39,8 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.SecurityContext;
+
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -55,11 +60,8 @@ public class QueryResources {
   @Produces(MediaType.TEXT_HTML)
   public Viewable getQuery() {
     return ViewableWithPermissions.create(
-        authEnabled.get(),
-        "/rest/query/query.ftl",
-        sc,
-        // if impersonation is enabled without authentication, will provide mechanism to add user name to request header from Web UI
-        WebServer.isOnlyImpersonationEnabled(work.getContext().getConfig()));
+        authEnabled.get(), "/rest/query/query.ftl",
+        sc, new QueryPage(work));
   }
 
   @POST
@@ -85,20 +87,56 @@ public class QueryResources {
     try {
       final String trimmedQueryString = CharMatcher.is(';').trimTrailingFrom(query.trim());
       final QueryResult result = submitQueryJSON(new QueryWrapper(trimmedQueryString, queryType));
-
-      return ViewableWithPermissions.create(authEnabled.get(), "/rest/query/result.ftl", sc, new TabularResult(result));
+      List<Integer> rowsPerPageValues = work.getContext().getConfig().getIntList(ExecConstants.HTTP_WEB_CLIENT_RESULTSET_ROWS_PER_PAGE_VALUES);
+      Collections.sort(rowsPerPageValues);
+      final String rowsPerPageValuesAsStr = Joiner.on(",").join(rowsPerPageValues);
+      return ViewableWithPermissions.create(authEnabled.get(), "/rest/query/result.ftl", sc, new TabularResult(result, rowsPerPageValuesAsStr));
     } catch (Exception | Error e) {
       logger.error("Query from Web UI Failed", e);
       return ViewableWithPermissions.create(authEnabled.get(), "/rest/query/errorMessage.ftl", sc, e);
     }
   }
 
+  /**
+   * Model class for Query page
+   */
+  public static class QueryPage {
+    private final boolean onlyImpersonationEnabled;
+    private final boolean autoLimitEnabled;
+    private final int defaultRowsAutoLimited;
+
+    public QueryPage(WorkManager work) {
+      DrillConfig config = work.getContext().getConfig();
+      //if impersonation is enabled without authentication, will provide mechanism to add user name to request header from Web UI
+      onlyImpersonationEnabled = WebServer.isOnlyImpersonationEnabled(config);
+      autoLimitEnabled = config.getBoolean(ExecConstants.HTTP_WEB_CLIENT_RESULTSET_AUTOLIMIT_CHECKED);
+      defaultRowsAutoLimited = config.getInt(ExecConstants.HTTP_WEB_CLIENT_RESULTSET_AUTOLIMIT_ROWS);
+    }
+
+    public boolean isOnlyImpersonationEnabled() {
+      return onlyImpersonationEnabled;
+    }
+
+    public boolean isAutoLimitEnabled() {
+      return autoLimitEnabled;
+    }
+
+    public int getDefaultRowsAutoLimited() {
+      return defaultRowsAutoLimited;
+    }
+  }
+
+  /**
+   * Model class for Results page
+   */
   public static class TabularResult {
     private final List<String> columns;
     private final List<List<String>> rows;
     private final String queryId;
+    private final String rowsPerPageValues;
 
-    public TabularResult(QueryResult result) {
+    public TabularResult(QueryResult result, String rowsPerPageValuesAsStr) {
+      rowsPerPageValues = rowsPerPageValuesAsStr;
       queryId = result.getQueryId();
       final List<List<String>> rows = Lists.newArrayList();
       for (Map<String, String> rowMap:result.rows) {
@@ -128,7 +166,11 @@ public class QueryResources {
     public List<List<String>> getRows() {
       return rows;
     }
-  }
 
+    //Used by results.ftl to render default number of pages per row
+    public String getRowsPerPageValues() {
+      return rowsPerPageValues;
+    }
+  }
 
 }
diff --git a/exec/java-exec/src/main/resources/drill-module.conf b/exec/java-exec/src/main/resources/drill-module.conf
index ac35cd9..4a5f075 100644
--- a/exec/java-exec/src/main/resources/drill-module.conf
+++ b/exec/java-exec/src/main/resources/drill-module.conf
@@ -167,6 +167,13 @@ drill.exec: {
             maximum: 9223372036854775807
         }
     },
+    web.client.resultset: {
+        autolimit {
+            checked: false,
+            rows: 1000
+        },
+        rowsPerPageValues: [10, 25, 50, 75, 100]
+    },
     web.options.filters: ["planner", "store", "parquet", "hashagg", "hashjoin"]
   },
   //setting javax variables for ssl configurations is being deprecated.
diff --git a/exec/java-exec/src/main/resources/rest/query/query.ftl b/exec/java-exec/src/main/resources/rest/query/query.ftl
index 38ed7c9..c4549f7 100644
--- a/exec/java-exec/src/main/resources/rest/query/query.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/query.ftl
@@ -41,7 +41,7 @@
 
 <#include "*/runningQuery.ftl">
 
-  <#if model?? && model>
+  <#if model.isOnlyImpersonationEnabled()>
      <div class="form-group">
        <label for="userName">User Name</label>
        <input type="text" size="30" name="userName" id="userName" placeholder="User Name">
@@ -77,9 +77,10 @@
       <input class="form-control" type="hidden" id="query" name="query"/>
     </div>
 
-    <button class="btn btn-default" type="button" onclick="<#if model?? && model>doSubmitQueryWithUserName()<#else>submitQuery()</#if>">
+    <button class="btn btn-default" type="button" onclick="<#if model.isOnlyImpersonationEnabled()>doSubmitQueryWithUserName()<#else>wrapAndSubmitQuery()</#if>">
       Submit
     </button>
+    <input type="checkbox" name="forceLimit" value="limit" <#if model.isAutoLimitEnabled()>checked</#if>> Limit results to <input type="text" id="queryLimit" min="0" value="${model.getDefaultRowsAutoLimited()}" size="6" pattern="[0-9]*"> rows <span class="glyphicon glyphicon-info-sign" onclick="alert('Limits the number of records retrieved in the query')" style="cursor:pointer"></span>
   </form>
 
   <script>
@@ -125,11 +126,10 @@
     document.getElementById('queryForm')
             .addEventListener('keydown', function(e) {
       if (!(e.keyCode == 13 && (e.metaKey || e.ctrlKey))) return;
-      if (e.target.form) 
-        <#if model?? && model>doSubmitQueryWithUserName()<#else>submitQuery()</#if>;
+      if (e.target.form) //Submit [Wrapped] Query 
+        <#if model.isOnlyImpersonationEnabled()>doSubmitQueryWithUserName()<#else>wrapAndSubmitQuery()</#if>;
     });
   </script>
-
 </#macro>
 
 <@page_html/>
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 7a17c64..9f16c1f 100644
--- a/exec/java-exec/src/main/resources/rest/query/result.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/result.ftl
@@ -74,7 +74,7 @@
       $('#result').dataTable( {
         "aaSorting": [],
         "scrollX" : true,
-        "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
+        "lengthMenu": [[${model.getRowsPerPageValues()},-1], [${model.getRowsPerPageValues()},"ALL"]],
         "lengthChange": true,
         "dom": '<"H"lCfr>t<"F"ip>',
         "jQueryUI" : true
diff --git a/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js b/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
index e62cc8f..1183682 100644
--- a/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
+++ b/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
@@ -15,6 +15,7 @@ var userName = null;
 var elapsedTime = 0;
 var delay = 1000; //msec
 var timeTracker = null; //Handle for stopping watch
+var userName = null;
 
 //Show cancellation status
 function popupAndWait() {
@@ -38,24 +39,33 @@ function closePopup() {
   $("#queryLoadingModal").modal("hide");
 }
 
-//Submit query with username
+// Wrap & Submit Query (invoked if impersonation is enabled to check for username)
 function doSubmitQueryWithUserName() {
-    var userName = document.getElementById("userName").value;
+    userName = document.getElementById("userName").value;
     if (!userName.trim()) {
         alert("Please fill in User Name field");
         return;
     }
+    //Wrap and Submit query
+    wrapAndSubmitQuery();
+}
+
+//Wrap & Submit Query (invoked directly if impersonation is not enabled)
+function wrapAndSubmitQuery() {
+    //Wrap if required
+    wrapQuery();
+    //Submit query
     submitQuery();
 }
 
-//Submit Query (used if impersonation is not enabled)
+//Submit Query
 function submitQuery() {
     popupAndWait();
     //Submit query
     $.ajax({
         type: "POST",
         beforeSend: function (request) {
-            if (typeof userName !== 'undefined' && userName != null && userName.length > 0) {
+            if (typeof userName !== 'undefined' && userName !== null && userName.length > 0) {
               request.setRequestHeader("User-Name", userName);
             }
         },
@@ -72,4 +82,26 @@ function submitQuery() {
             alert(errorThrown);
         }
     });
-}
\ No newline at end of file
+}
+
+//Wraps a query with Limit by directly changing the query in the hidden textbox in the UI (see /query.ftl)
+function wrapQuery() {
+    var origQueryText = $('#query').attr('value');
+    //dBug: console.log("Query Input:" + origQueryText);
+    var mustWrapWithLimit = $('input[name="forceLimit"]:checked').length > 0;
+    if (mustWrapWithLimit) {
+        var semicolonIdx = origQueryText.lastIndexOf(';');
+        //Check and eliminate trailing semicolon
+        if (semicolonIdx  == origQueryText.length-1 ) {
+          origQueryText = origQueryText.substring(0, semicolonIdx)
+        }
+        var qLimit = $('#queryLimit').val();
+        var wrappedQuery = "-- [autoLimit: " + qLimit + " rows]\nselect * from (\n" + origQueryText + "\n) limit " + qLimit;
+        //dBug: console.log("Query Output:" + wrappedQuery);
+        //Wrapping Query
+        $('#query').attr('value', wrappedQuery);
+    } else {
+        //Do not change the query
+        //dBug: console.log("Query Output:" + origQueryText);
+    }
+}


[drill] 01/05: DRILL-6946: Implement java.sql.Connection setSchema and getSchema methods in DrillConnectionImpl closes #1596

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

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

commit 814e9f099bf917c22a91a0a8f36d6afef3eac37f
Author: Arina Ielchiieva <ar...@gmail.com>
AuthorDate: Wed Jan 2 20:05:12 2019 +0200

    DRILL-6946: Implement java.sql.Connection setSchema and getSchema methods in DrillConnectionImpl
    closes #1596
---
 contrib/native/client/src/protobuf/User.pb.cc      | 196 ++++++++----
 contrib/native/client/src/protobuf/User.pb.h       |  87 +++++-
 .../exec/work/metadata/ServerMetaProvider.java     |   3 +-
 .../exec/work/metadata/TestServerMetaProvider.java |  43 ++-
 .../drill/jdbc/impl/DrillConnectionImpl.java       |  31 ++
 .../org/apache/drill/jdbc/ConnectionInfoTest.java  |  85 ++++--
 .../apache/drill/exec/proto/SchemaUserProtos.java  |   7 +
 .../org/apache/drill/exec/proto/UserProtos.java    | 336 +++++++++++++++++----
 .../apache/drill/exec/proto/beans/ServerMeta.java  |  22 ++
 protocol/src/main/protobuf/User.proto              |   2 +
 10 files changed, 634 insertions(+), 178 deletions(-)

diff --git a/contrib/native/client/src/protobuf/User.pb.cc b/contrib/native/client/src/protobuf/User.pb.cc
index e2ae3d1..a0e2acd 100644
--- a/contrib/native/client/src/protobuf/User.pb.cc
+++ b/contrib/native/client/src/protobuf/User.pb.cc
@@ -671,7 +671,7 @@ void protobuf_AssignDesc_User_2eproto() {
       ::google::protobuf::MessageFactory::generated_factory(),
       sizeof(GetServerMetaResp));
   ServerMeta_descriptor_ = file->message_type(29);
-  static const int ServerMeta_offsets_[49] = {
+  static const int ServerMeta_offsets_[50] = {
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, all_tables_selectable_),
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, blob_included_in_max_row_size_),
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, catalog_at_start_),
@@ -721,6 +721,7 @@ void protobuf_AssignDesc_User_2eproto() {
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, table_term_),
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, transaction_supported_),
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, union_support_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, current_schema_),
   };
   ServerMeta_reflection_ =
     new ::google::protobuf::internal::GeneratedMessageReflection(
@@ -1039,7 +1040,7 @@ void protobuf_AddDesc_User_2eproto() {
     "verMetaResp\022(\n\006status\030\001 \001(\0162\030.exec.user."
     "RequestStatus\022*\n\013server_meta\030\002 \001(\0132\025.exe"
     "c.user.ServerMeta\022(\n\005error\030\003 \001(\0132\031.exec."
-    "shared.DrillPBError\"\377\r\n\nServerMeta\022\035\n\025al"
+    "shared.DrillPBError\"\227\016\n\nServerMeta\022\035\n\025al"
     "l_tables_selectable\030\001 \001(\010\022%\n\035blob_includ"
     "ed_in_max_row_size\030\002 \001(\010\022\030\n\020catalog_at_s"
     "tart\030\003 \001(\010\022\031\n\021catalog_separator\030\004 \001(\t\022\024\n"
@@ -1084,70 +1085,70 @@ void protobuf_AddDesc_User_2eproto() {
     "ySupport\022\030\n\020system_functions\030. \003(\t\022\022\n\nta"
     "ble_term\030/ \001(\t\022\035\n\025transaction_supported\030"
     "0 \001(\010\022.\n\runion_support\0301 \003(\0162\027.exec.user"
-    ".UnionSupport\"\353\001\n\010RunQuery\0221\n\014results_mo"
-    "de\030\001 \001(\0162\033.exec.user.QueryResultsMode\022$\n"
-    "\004type\030\002 \001(\0162\026.exec.shared.QueryType\022\014\n\004p"
-    "lan\030\003 \001(\t\0221\n\tfragments\030\004 \003(\0132\036.exec.bit."
-    "control.PlanFragment\022E\n\031prepared_stateme"
-    "nt_handle\030\005 \001(\0132\".exec.user.PreparedStat"
-    "ementHandle*\320\003\n\007RpcType\022\r\n\tHANDSHAKE\020\000\022\007"
-    "\n\003ACK\020\001\022\013\n\007GOODBYE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014C"
-    "ANCEL_QUERY\020\004\022\023\n\017REQUEST_RESULTS\020\005\022\027\n\023RE"
-    "SUME_PAUSED_QUERY\020\013\022\034\n\030GET_QUERY_PLAN_FR"
-    "AGMENTS\020\014\022\020\n\014GET_CATALOGS\020\016\022\017\n\013GET_SCHEM"
-    "AS\020\017\022\016\n\nGET_TABLES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n"
-    "\031CREATE_PREPARED_STATEMENT\020\026\022\023\n\017GET_SERV"
-    "ER_META\020\010\022\016\n\nQUERY_DATA\020\006\022\020\n\014QUERY_HANDL"
-    "E\020\007\022\030\n\024QUERY_PLAN_FRAGMENTS\020\r\022\014\n\010CATALOG"
-    "S\020\022\022\013\n\007SCHEMAS\020\023\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020"
-    "\025\022\026\n\022PREPARED_STATEMENT\020\027\022\017\n\013SERVER_META"
-    "\020\t\022\020\n\014QUERY_RESULT\020\n\022\020\n\014SASL_MESSAGE\020\030*H"
-    "\n\013SaslSupport\022\030\n\024UNKNOWN_SASL_SUPPORT\020\000\022"
-    "\r\n\tSASL_AUTH\020\001\022\020\n\014SASL_PRIVACY\020\002*#\n\020Quer"
-    "yResultsMode\022\017\n\013STREAM_FULL\020\001*q\n\017Handsha"
-    "keStatus\022\013\n\007SUCCESS\020\001\022\030\n\024RPC_VERSION_MIS"
-    "MATCH\020\002\022\017\n\013AUTH_FAILED\020\003\022\023\n\017UNKNOWN_FAIL"
-    "URE\020\004\022\021\n\rAUTH_REQUIRED\020\005*D\n\rRequestStatu"
-    "s\022\022\n\016UNKNOWN_STATUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020"
-    "\002\022\013\n\007TIMEOUT\020\003*Y\n\023ColumnSearchability\022\031\n"
-    "\025UNKNOWN_SEARCHABILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CH"
-    "AR\020\002\022\n\n\006NUMBER\020\003\022\007\n\003ALL\020\004*K\n\022ColumnUpdat"
-    "ability\022\030\n\024UNKNOWN_UPDATABILITY\020\000\022\r\n\tREA"
-    "D_ONLY\020\001\022\014\n\010WRITABLE\020\002*1\n\016CollateSupport"
-    "\022\016\n\nCS_UNKNOWN\020\000\022\017\n\013CS_GROUP_BY\020\001*J\n\027Cor"
-    "relationNamesSupport\022\013\n\007CN_NONE\020\001\022\026\n\022CN_"
-    "DIFFERENT_NAMES\020\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTi"
-    "meLiteralsSupport\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_"
-    "DATE\020\001\022\013\n\007DL_TIME\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n"
-    "\020DL_INTERVAL_YEAR\020\004\022\025\n\021DL_INTERVAL_MONTH"
-    "\020\005\022\023\n\017DL_INTERVAL_DAY\020\006\022\024\n\020DL_INTERVAL_H"
-    "OUR\020\007\022\026\n\022DL_INTERVAL_MINUTE\020\010\022\026\n\022DL_INTE"
-    "RVAL_SECOND\020\t\022\035\n\031DL_INTERVAL_YEAR_TO_MON"
-    "TH\020\n\022\033\n\027DL_INTERVAL_DAY_TO_HOUR\020\013\022\035\n\031DL_"
-    "INTERVAL_DAY_TO_MINUTE\020\014\022\035\n\031DL_INTERVAL_"
-    "DAY_TO_SECOND\020\r\022\036\n\032DL_INTERVAL_HOUR_TO_M"
-    "INUTE\020\016\022\036\n\032DL_INTERVAL_HOUR_TO_SECOND\020\017\022"
-    " \n\034DL_INTERVAL_MINUTE_TO_SECOND\020\020*Y\n\016Gro"
-    "upBySupport\022\013\n\007GB_NONE\020\001\022\022\n\016GB_SELECT_ON"
-    "LY\020\002\022\024\n\020GB_BEYOND_SELECT\020\003\022\020\n\014GB_UNRELAT"
-    "ED\020\004*x\n\020IdentifierCasing\022\016\n\nIC_UNKNOWN\020\000"
-    "\022\023\n\017IC_STORES_LOWER\020\001\022\023\n\017IC_STORES_MIXED"
-    "\020\002\022\023\n\017IC_STORES_UPPER\020\003\022\025\n\021IC_SUPPORTS_M"
-    "IXED\020\004*X\n\rNullCollation\022\016\n\nNC_UNKNOWN\020\000\022"
-    "\017\n\013NC_AT_START\020\001\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HI"
-    "GH\020\003\022\n\n\006NC_LOW\020\004*E\n\016OrderBySupport\022\016\n\nOB"
-    "_UNKNOWN\020\000\022\020\n\014OB_UNRELATED\020\001\022\021\n\rOB_EXPRE"
-    "SSION\020\002*\226\001\n\020OuterJoinSupport\022\016\n\nOJ_UNKNO"
-    "WN\020\000\022\013\n\007OJ_LEFT\020\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FU"
-    "LL\020\003\022\r\n\tOJ_NESTED\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022"
-    "\014\n\010OJ_INNER\020\006\022\031\n\025OJ_ALL_COMPARISON_OPS\020\007"
-    "*\204\001\n\017SubQuerySupport\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\r"
-    "SQ_CORRELATED\020\001\022\024\n\020SQ_IN_COMPARISON\020\002\022\020\n"
-    "\014SQ_IN_EXISTS\020\003\022\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_"
-    "IN_QUANTIFIED\020\005*;\n\014UnionSupport\022\r\n\tU_UNK"
-    "NOWN\020\000\022\013\n\007U_UNION\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033"
-    "org.apache.drill.exec.protoB\nUserProtosH"
-    "\001", 8881);
+    ".UnionSupport\022\026\n\016current_schema\0302 \001(\t\"\353\001"
+    "\n\010RunQuery\0221\n\014results_mode\030\001 \001(\0162\033.exec."
+    "user.QueryResultsMode\022$\n\004type\030\002 \001(\0162\026.ex"
+    "ec.shared.QueryType\022\014\n\004plan\030\003 \001(\t\0221\n\tfra"
+    "gments\030\004 \003(\0132\036.exec.bit.control.PlanFrag"
+    "ment\022E\n\031prepared_statement_handle\030\005 \001(\0132"
+    "\".exec.user.PreparedStatementHandle*\320\003\n\007"
+    "RpcType\022\r\n\tHANDSHAKE\020\000\022\007\n\003ACK\020\001\022\013\n\007GOODB"
+    "YE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014CANCEL_QUERY\020\004\022\023\n"
+    "\017REQUEST_RESULTS\020\005\022\027\n\023RESUME_PAUSED_QUER"
+    "Y\020\013\022\034\n\030GET_QUERY_PLAN_FRAGMENTS\020\014\022\020\n\014GET"
+    "_CATALOGS\020\016\022\017\n\013GET_SCHEMAS\020\017\022\016\n\nGET_TABL"
+    "ES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n\031CREATE_PREPARED"
+    "_STATEMENT\020\026\022\023\n\017GET_SERVER_META\020\010\022\016\n\nQUE"
+    "RY_DATA\020\006\022\020\n\014QUERY_HANDLE\020\007\022\030\n\024QUERY_PLA"
+    "N_FRAGMENTS\020\r\022\014\n\010CATALOGS\020\022\022\013\n\007SCHEMAS\020\023"
+    "\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020\025\022\026\n\022PREPARED_ST"
+    "ATEMENT\020\027\022\017\n\013SERVER_META\020\t\022\020\n\014QUERY_RESU"
+    "LT\020\n\022\020\n\014SASL_MESSAGE\020\030*H\n\013SaslSupport\022\030\n"
+    "\024UNKNOWN_SASL_SUPPORT\020\000\022\r\n\tSASL_AUTH\020\001\022\020"
+    "\n\014SASL_PRIVACY\020\002*#\n\020QueryResultsMode\022\017\n\013"
+    "STREAM_FULL\020\001*q\n\017HandshakeStatus\022\013\n\007SUCC"
+    "ESS\020\001\022\030\n\024RPC_VERSION_MISMATCH\020\002\022\017\n\013AUTH_"
+    "FAILED\020\003\022\023\n\017UNKNOWN_FAILURE\020\004\022\021\n\rAUTH_RE"
+    "QUIRED\020\005*D\n\rRequestStatus\022\022\n\016UNKNOWN_STA"
+    "TUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020\002\022\013\n\007TIMEOUT\020\003*Y"
+    "\n\023ColumnSearchability\022\031\n\025UNKNOWN_SEARCHA"
+    "BILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CHAR\020\002\022\n\n\006NUMBER\020\003"
+    "\022\007\n\003ALL\020\004*K\n\022ColumnUpdatability\022\030\n\024UNKNO"
+    "WN_UPDATABILITY\020\000\022\r\n\tREAD_ONLY\020\001\022\014\n\010WRIT"
+    "ABLE\020\002*1\n\016CollateSupport\022\016\n\nCS_UNKNOWN\020\000"
+    "\022\017\n\013CS_GROUP_BY\020\001*J\n\027CorrelationNamesSup"
+    "port\022\013\n\007CN_NONE\020\001\022\026\n\022CN_DIFFERENT_NAMES\020"
+    "\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTimeLiteralsSuppor"
+    "t\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_DATE\020\001\022\013\n\007DL_TIM"
+    "E\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n\020DL_INTERVAL_YEA"
+    "R\020\004\022\025\n\021DL_INTERVAL_MONTH\020\005\022\023\n\017DL_INTERVA"
+    "L_DAY\020\006\022\024\n\020DL_INTERVAL_HOUR\020\007\022\026\n\022DL_INTE"
+    "RVAL_MINUTE\020\010\022\026\n\022DL_INTERVAL_SECOND\020\t\022\035\n"
+    "\031DL_INTERVAL_YEAR_TO_MONTH\020\n\022\033\n\027DL_INTER"
+    "VAL_DAY_TO_HOUR\020\013\022\035\n\031DL_INTERVAL_DAY_TO_"
+    "MINUTE\020\014\022\035\n\031DL_INTERVAL_DAY_TO_SECOND\020\r\022"
+    "\036\n\032DL_INTERVAL_HOUR_TO_MINUTE\020\016\022\036\n\032DL_IN"
+    "TERVAL_HOUR_TO_SECOND\020\017\022 \n\034DL_INTERVAL_M"
+    "INUTE_TO_SECOND\020\020*Y\n\016GroupBySupport\022\013\n\007G"
+    "B_NONE\020\001\022\022\n\016GB_SELECT_ONLY\020\002\022\024\n\020GB_BEYON"
+    "D_SELECT\020\003\022\020\n\014GB_UNRELATED\020\004*x\n\020Identifi"
+    "erCasing\022\016\n\nIC_UNKNOWN\020\000\022\023\n\017IC_STORES_LO"
+    "WER\020\001\022\023\n\017IC_STORES_MIXED\020\002\022\023\n\017IC_STORES_"
+    "UPPER\020\003\022\025\n\021IC_SUPPORTS_MIXED\020\004*X\n\rNullCo"
+    "llation\022\016\n\nNC_UNKNOWN\020\000\022\017\n\013NC_AT_START\020\001"
+    "\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HIGH\020\003\022\n\n\006NC_LOW\020\004"
+    "*E\n\016OrderBySupport\022\016\n\nOB_UNKNOWN\020\000\022\020\n\014OB"
+    "_UNRELATED\020\001\022\021\n\rOB_EXPRESSION\020\002*\226\001\n\020Oute"
+    "rJoinSupport\022\016\n\nOJ_UNKNOWN\020\000\022\013\n\007OJ_LEFT\020"
+    "\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FULL\020\003\022\r\n\tOJ_NESTE"
+    "D\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022\014\n\010OJ_INNER\020\006\022\031\n"
+    "\025OJ_ALL_COMPARISON_OPS\020\007*\204\001\n\017SubQuerySup"
+    "port\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\rSQ_CORRELATED\020\001\022"
+    "\024\n\020SQ_IN_COMPARISON\020\002\022\020\n\014SQ_IN_EXISTS\020\003\022"
+    "\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_IN_QUANTIFIED\020\005*"
+    ";\n\014UnionSupport\022\r\n\tU_UNKNOWN\020\000\022\013\n\007U_UNIO"
+    "N\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033org.apache.drill"
+    ".exec.protoB\nUserProtosH\001", 8905);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "User.proto", &protobuf_RegisterTypes);
   Property::default_instance_ = new Property();
@@ -12284,6 +12285,7 @@ const int ServerMeta::kSystemFunctionsFieldNumber;
 const int ServerMeta::kTableTermFieldNumber;
 const int ServerMeta::kTransactionSupportedFieldNumber;
 const int ServerMeta::kUnionSupportFieldNumber;
+const int ServerMeta::kCurrentSchemaFieldNumber;
 #endif  // !_MSC_VER
 
 ServerMeta::ServerMeta()
@@ -12339,6 +12341,7 @@ void ServerMeta::SharedCtor() {
   special_characters_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
   table_term_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
   transaction_supported_ = false;
+  current_schema_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
   ::memset(_has_bits_, 0, sizeof(_has_bits_));
 }
 
@@ -12368,6 +12371,9 @@ void ServerMeta::SharedDtor() {
   if (table_term_ != &::google::protobuf::internal::kEmptyString) {
     delete table_term_;
   }
+  if (current_schema_ != &::google::protobuf::internal::kEmptyString) {
+    delete current_schema_;
+  }
   if (this != default_instance_) {
   }
 }
@@ -12471,6 +12477,13 @@ void ServerMeta::Clear() {
     }
     transaction_supported_ = false;
   }
+  if (_has_bits_[49 / 32] & (0xffu << (49 % 32))) {
+    if (has_current_schema()) {
+      if (current_schema_ != &::google::protobuf::internal::kEmptyString) {
+        current_schema_->clear();
+      }
+    }
+  }
   collate_support_.Clear();
   convert_support_.Clear();
   date_time_functions_.Clear();
@@ -13396,6 +13409,23 @@ bool ServerMeta::MergePartialFromCodedStream(
           goto handle_uninterpreted;
         }
         if (input->ExpectTag(392)) goto parse_union_support;
+        if (input->ExpectTag(402)) goto parse_current_schema;
+        break;
+      }
+
+      // optional string current_schema = 50;
+      case 50: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+         parse_current_schema:
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_current_schema()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+            this->current_schema().data(), this->current_schema().length(),
+            ::google::protobuf::internal::WireFormat::PARSE);
+        } else {
+          goto handle_uninterpreted;
+        }
         if (input->ExpectAtEnd()) return true;
         break;
       }
@@ -13723,6 +13753,15 @@ void ServerMeta::SerializeWithCachedSizes(
       49, this->union_support(i), output);
   }
 
+  // optional string current_schema = 50;
+  if (has_current_schema()) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+      this->current_schema().data(), this->current_schema().length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE);
+    ::google::protobuf::internal::WireFormatLite::WriteString(
+      50, this->current_schema(), output);
+  }
+
   if (!unknown_fields().empty()) {
     ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
         unknown_fields(), output);
@@ -14044,6 +14083,16 @@ void ServerMeta::SerializeWithCachedSizes(
       49, this->union_support(i), target);
   }
 
+  // optional string current_schema = 50;
+  if (has_current_schema()) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+      this->current_schema().data(), this->current_schema().length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE);
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        50, this->current_schema(), target);
+  }
+
   if (!unknown_fields().empty()) {
     target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
         unknown_fields(), target);
@@ -14302,6 +14351,15 @@ int ServerMeta::ByteSize() const {
     }
 
   }
+  if (_has_bits_[49 / 32] & (0xffu << (49 % 32))) {
+    // optional string current_schema = 50;
+    if (has_current_schema()) {
+      total_size += 2 +
+        ::google::protobuf::internal::WireFormatLite::StringSize(
+          this->current_schema());
+    }
+
+  }
   // repeated .exec.user.CollateSupport collate_support = 6;
   {
     int data_size = 0;
@@ -14565,6 +14623,11 @@ void ServerMeta::MergeFrom(const ServerMeta& from) {
       set_transaction_supported(from.transaction_supported());
     }
   }
+  if (from._has_bits_[49 / 32] & (0xffu << (49 % 32))) {
+    if (from.has_current_schema()) {
+      set_current_schema(from.current_schema());
+    }
+  }
   mutable_unknown_fields()->MergeFrom(from.unknown_fields());
 }
 
@@ -14639,6 +14702,7 @@ void ServerMeta::Swap(ServerMeta* other) {
     std::swap(table_term_, other->table_term_);
     std::swap(transaction_supported_, other->transaction_supported_);
     union_support_.Swap(&other->union_support_);
+    std::swap(current_schema_, other->current_schema_);
     std::swap(_has_bits_[0], other->_has_bits_[0]);
     std::swap(_has_bits_[1], other->_has_bits_[1]);
     _unknown_fields_.Swap(&other->_unknown_fields_);
diff --git a/contrib/native/client/src/protobuf/User.pb.h b/contrib/native/client/src/protobuf/User.pb.h
index b50e8c3..df8a45d 100644
--- a/contrib/native/client/src/protobuf/User.pb.h
+++ b/contrib/native/client/src/protobuf/User.pb.h
@@ -4567,6 +4567,18 @@ class ServerMeta : public ::google::protobuf::Message {
   inline const ::google::protobuf::RepeatedField<int>& union_support() const;
   inline ::google::protobuf::RepeatedField<int>* mutable_union_support();
 
+  // optional string current_schema = 50;
+  inline bool has_current_schema() const;
+  inline void clear_current_schema();
+  static const int kCurrentSchemaFieldNumber = 50;
+  inline const ::std::string& current_schema() const;
+  inline void set_current_schema(const ::std::string& value);
+  inline void set_current_schema(const char* value);
+  inline void set_current_schema(const char* value, size_t size);
+  inline ::std::string* mutable_current_schema();
+  inline ::std::string* release_current_schema();
+  inline void set_allocated_current_schema(::std::string* current_schema);
+
   // @@protoc_insertion_point(class_scope:exec.user.ServerMeta)
  private:
   inline void set_has_all_tables_selectable();
@@ -4643,6 +4655,8 @@ class ServerMeta : public ::google::protobuf::Message {
   inline void clear_has_table_term();
   inline void set_has_transaction_supported();
   inline void clear_has_transaction_supported();
+  inline void set_has_current_schema();
+  inline void clear_has_current_schema();
 
   ::google::protobuf::UnknownFieldSet _unknown_fields_;
 
@@ -4695,9 +4709,10 @@ class ServerMeta : public ::google::protobuf::Message {
   ::google::protobuf::RepeatedPtrField< ::std::string> system_functions_;
   ::std::string* table_term_;
   ::google::protobuf::RepeatedField<int> union_support_;
+  ::std::string* current_schema_;
 
   mutable int _cached_size_;
-  ::google::protobuf::uint32 _has_bits_[(49 + 31) / 32];
+  ::google::protobuf::uint32 _has_bits_[(50 + 31) / 32];
 
   friend void  protobuf_AddDesc_User_2eproto();
   friend void protobuf_AssignDesc_User_2eproto();
@@ -11602,6 +11617,76 @@ ServerMeta::mutable_union_support() {
   return &union_support_;
 }
 
+// optional string current_schema = 50;
+inline bool ServerMeta::has_current_schema() const {
+  return (_has_bits_[1] & 0x00020000u) != 0;
+}
+inline void ServerMeta::set_has_current_schema() {
+  _has_bits_[1] |= 0x00020000u;
+}
+inline void ServerMeta::clear_has_current_schema() {
+  _has_bits_[1] &= ~0x00020000u;
+}
+inline void ServerMeta::clear_current_schema() {
+  if (current_schema_ != &::google::protobuf::internal::kEmptyString) {
+    current_schema_->clear();
+  }
+  clear_has_current_schema();
+}
+inline const ::std::string& ServerMeta::current_schema() const {
+  return *current_schema_;
+}
+inline void ServerMeta::set_current_schema(const ::std::string& value) {
+  set_has_current_schema();
+  if (current_schema_ == &::google::protobuf::internal::kEmptyString) {
+    current_schema_ = new ::std::string;
+  }
+  current_schema_->assign(value);
+}
+inline void ServerMeta::set_current_schema(const char* value) {
+  set_has_current_schema();
+  if (current_schema_ == &::google::protobuf::internal::kEmptyString) {
+    current_schema_ = new ::std::string;
+  }
+  current_schema_->assign(value);
+}
+inline void ServerMeta::set_current_schema(const char* value, size_t size) {
+  set_has_current_schema();
+  if (current_schema_ == &::google::protobuf::internal::kEmptyString) {
+    current_schema_ = new ::std::string;
+  }
+  current_schema_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* ServerMeta::mutable_current_schema() {
+  set_has_current_schema();
+  if (current_schema_ == &::google::protobuf::internal::kEmptyString) {
+    current_schema_ = new ::std::string;
+  }
+  return current_schema_;
+}
+inline ::std::string* ServerMeta::release_current_schema() {
+  clear_has_current_schema();
+  if (current_schema_ == &::google::protobuf::internal::kEmptyString) {
+    return NULL;
+  } else {
+    ::std::string* temp = current_schema_;
+    current_schema_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+    return temp;
+  }
+}
+inline void ServerMeta::set_allocated_current_schema(::std::string* current_schema) {
+  if (current_schema_ != &::google::protobuf::internal::kEmptyString) {
+    delete current_schema_;
+  }
+  if (current_schema) {
+    set_has_current_schema();
+    current_schema_ = current_schema;
+  } else {
+    clear_has_current_schema();
+    current_schema_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+  }
+}
+
 // -------------------------------------------------------------------
 
 // RunQuery
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java
index 4f7bffc..97df542 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java
@@ -138,7 +138,8 @@ public class ServerMetaProvider {
           .setIdentifierQuoteString(config.quoting().string)
           .setIdentifierCasing(getIdentifierCasing(config.unquotedCasing(), config.caseSensitive()))
           .setQuotedIdentifierCasing(getIdentifierCasing(config.quotedCasing(), config.caseSensitive()))
-          .addAllSqlKeywords(Splitter.on(",").split(metadata.getJdbcKeywords()));
+          .addAllSqlKeywords(Splitter.on(",").split(metadata.getJdbcKeywords()))
+          .setCurrentSchema(session.getDefaultSchemaPath());
         respBuilder.setServerMeta(metaBuilder);
         respBuilder.setStatus(RequestStatus.OK);
       } catch(Throwable t) {
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java b/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java
index 46f27a6..b8acd2c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java
@@ -21,28 +21,43 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import org.apache.calcite.avatica.util.Quoting;
-import org.apache.drill.test.BaseTestQuery;
 import org.apache.drill.exec.proto.UserProtos.GetServerMetaResp;
 import org.apache.drill.exec.proto.UserProtos.RequestStatus;
-import org.apache.drill.exec.proto.UserProtos.ServerMeta;
+import org.apache.drill.test.ClusterFixture;
+import org.apache.drill.test.ClusterFixtureBuilder;
+import org.apache.drill.test.ClusterTest;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
-/**
- * Tests for server metadata provider APIs.
- */
-public class TestServerMetaProvider extends BaseTestQuery {
-  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestServerMetaProvider.class);
+public class TestServerMetaProvider extends ClusterTest {
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
+    startCluster(builder);
+  }
 
   @Test
   public void testServerMeta() throws Exception {
-    GetServerMetaResp resp = client.getServerMeta().get();
-    assertNotNull(resp);
-    assertEquals(RequestStatus.OK, resp.getStatus());
-    assertNotNull(resp.getServerMeta());
+    GetServerMetaResp response = client.client().getServerMeta().get();
+    assertNotNull(response);
+    assertEquals(RequestStatus.OK, response.getStatus());
+    assertNotNull(response.getServerMeta());
+
+    assertEquals(Quoting.BACK_TICK.string, response.getServerMeta().getIdentifierQuoteString());
+  }
+
+  @Test
+  public void testCurrentSchema() throws Exception {
+    GetServerMetaResp response = client.client().getServerMeta().get();
+    assertEquals(RequestStatus.OK, response.getStatus());
+    assertEquals("", response.getServerMeta().getCurrentSchema());
 
-    ServerMeta serverMeta = resp.getServerMeta();
-    logger.trace("Server metadata: {}", serverMeta);
+    queryBuilder().sql("use dfs.tmp").run();
 
-    assertEquals(Quoting.BACK_TICK.string, serverMeta.getIdentifierQuoteString());
+    response = client.client().getServerMeta().get();
+    assertEquals(RequestStatus.OK, response.getStatus());
+    assertEquals("dfs.tmp", response.getServerMeta().getCurrentSchema());
   }
+
 }
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java
index df23f40..d83369e 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java
@@ -34,6 +34,7 @@ import java.sql.Struct;
 import java.util.Map;
 import java.util.Properties;
 import java.util.TimeZone;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executor;
 
 import org.apache.calcite.avatica.AvaticaConnection;
@@ -44,6 +45,7 @@ import org.apache.calcite.avatica.Meta.MetaResultSet;
 import org.apache.calcite.avatica.NoSuchStatementException;
 import org.apache.calcite.avatica.QueryState;
 import org.apache.calcite.avatica.UnregisteredDriver;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.exceptions.DrillRuntimeException;
 import org.apache.drill.common.exceptions.UserException;
@@ -52,6 +54,8 @@ import org.apache.drill.exec.client.InvalidConnectionInfoException;
 import org.apache.drill.exec.exception.OutOfMemoryException;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.RootAllocatorFactory;
+import org.apache.drill.exec.proto.UserBitShared;
+import org.apache.drill.exec.proto.UserProtos;
 import org.apache.drill.exec.rpc.RpcException;
 import org.apache.drill.exec.server.Drillbit;
 import org.apache.drill.exec.server.RemoteServiceSet;
@@ -583,6 +587,33 @@ public class DrillConnectionImpl extends AvaticaConnection
   }
 
   @Override
+  public void setSchema(String schema) throws SQLException {
+    checkOpen();
+    try {
+      client.runQuery(UserBitShared.QueryType.SQL, String.format("use %s", schema));
+    } catch (RpcException e) {
+      throw new SQLException("Error when setting schema", e);
+    }
+  }
+
+  @Override
+  public String getSchema() throws SQLException {
+    checkOpen();
+    try {
+      UserProtos.GetServerMetaResp response = client.getServerMeta().get();
+      if (response.getStatus() != UserProtos.RequestStatus.OK) {
+        UserBitShared.DrillPBError drillError = response.getError();
+        throw new SQLException("Error when getting server meta: " + drillError.getMessage());
+      }
+      UserProtos.ServerMeta serverMeta = response.getServerMeta();
+      String currentSchema = serverMeta.hasCurrentSchema() ? serverMeta.getCurrentSchema() : null;
+      return StringUtils.isEmpty(currentSchema) ? null : currentSchema;
+    } catch (InterruptedException | ExecutionException e) {
+      throw new SQLException("Error when getting server meta", e);
+    }
+  }
+
+  @Override
   public void abort(Executor executor) throws SQLException {
     checkOpen();
     try {
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java
index c24c2b8..c2a3ebd 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java
@@ -20,8 +20,11 @@ package org.apache.drill.jdbc;
 import org.apache.calcite.avatica.util.Quoting;
 import org.apache.drill.categories.JdbcTest;
 import org.apache.drill.categories.SlowTest;
+import org.junit.After;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
@@ -29,6 +32,8 @@ import java.sql.SQLException;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 
 /**
@@ -36,39 +41,59 @@ import static org.junit.Assert.assertThat;
  */
 @Category({SlowTest.class, JdbcTest.class})
 public class ConnectionInfoTest extends JdbcTestBase {
-  private static Connection connection;
-  private static DatabaseMetaData dbmd;
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  @After
+  public void tearDown() {
+    reset();
+  }
+
+  @Test
+  public void testQuotingIdentifiersProperty() throws Exception {
+    Connection connection = connect("jdbc:drill:zk=local;quoting_identifiers='\"'");
+    DatabaseMetaData dbmd = connection.getMetaData();
+    assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.DOUBLE_QUOTE.string));
+
+    reset();
+
+    connection = connect("jdbc:drill:zk=local;quoting_identifiers=[");
+    dbmd = connection.getMetaData();
+    assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.BRACKET.string));
+  }
+
+  @Test
+  public void testIncorrectCharacterForQuotingIdentifiers() throws Exception {
+    thrown.expect(SQLException.class);
+    thrown.expectMessage(containsString("Option planner.parser.quoting_identifiers must be one of: [`, \", []"));
+
+    connect("jdbc:drill:zk=local;quoting_identifiers=&");
+  }
+
+  @Test
+  public void testSetSchemaUsingConnectionMethod() throws Exception {
+    Connection connection = connect("jdbc:drill:zk=local");
+    assertNull(connection.getSchema());
+
+    connection.setSchema("dfs.tmp");
+    assertEquals("dfs.tmp", connection.getSchema());
+  }
 
   @Test
-  public void testQuotingIdentifiersProperty() throws SQLException {
-    try {
-      // Test DoubleQuotes for the DrillProperty#QUOTING_IDENTIFIERS in connection URL
-      connection = connect("jdbc:drill:zk=local;quoting_identifiers='\"'");
-      dbmd = connection.getMetaData();
-      assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.DOUBLE_QUOTE.string));
-      reset();
-
-      // Test Brackets for the DrillProperty#QUOTING_IDENTIFIERS in connection URL
-      connection = connect("jdbc:drill:zk=local;quoting_identifiers=[");
-      dbmd = connection.getMetaData();
-      assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.BRACKET.string));
-    } finally {
-      reset();
-    }
+  public void testIncorrectlySetSchema() throws Exception {
+    Connection connection = connect("jdbc:drill:zk=local");
+
+    thrown.expect(SQLException.class);
+    thrown.expectMessage("Error when setting schema");
+
+    connection.setSchema("ABC");
   }
 
-  @Test(expected = SQLException.class)
-  public void testIncorrectCharacterForQuotingIdentifiers() throws SQLException {
-    try {
-      connection = connect("jdbc:drill:zk=local;quoting_identifiers=&");
-    }
-    catch (SQLException e) {
-      // Check exception text message
-      assertThat(e.getMessage(), containsString("Option planner.parser.quoting_identifiers " +
-          "must be one of: [`, \", []"));
-      throw e;
-    } finally {
-      reset();
-    }
+  @Test
+  public void testSchemaInConnectionString() throws Exception {
+    Connection connection = connect("jdbc:drill:zk=local;schema=sys");
+    assertEquals("sys", connection.getSchema());
   }
+
 }
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java b/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java
index c1c02ea..899d767 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java
@@ -4078,6 +4078,8 @@ public final class SchemaUserProtos
                     output.writeBool(48, message.getTransactionSupported(), false);
                 for(org.apache.drill.exec.proto.UserProtos.UnionSupport unionSupport : message.getUnionSupportList())
                     output.writeEnum(49, unionSupport.getNumber(), true);
+                if(message.hasCurrentSchema())
+                    output.writeString(50, message.getCurrentSchema(), false);
             }
             public boolean isInitialized(org.apache.drill.exec.proto.UserProtos.ServerMeta message)
             {
@@ -4265,6 +4267,9 @@ public final class SchemaUserProtos
                         case 49:
                             builder.addUnionSupport(org.apache.drill.exec.proto.UserProtos.UnionSupport.valueOf(input.readEnum()));
                             break;
+                        case 50:
+                            builder.setCurrentSchema(input.readString());
+                            break;
                         default:
                             input.handleUnknownField(number, this);
                     }
@@ -4354,6 +4359,7 @@ public final class SchemaUserProtos
                 case 47: return "tableTerm";
                 case 48: return "transactionSupported";
                 case 49: return "unionSupport";
+                case 50: return "currentSchema";
                 default: return null;
             }
         }
@@ -4414,6 +4420,7 @@ public final class SchemaUserProtos
             fieldMap.put("tableTerm", 47);
             fieldMap.put("transactionSupported", 48);
             fieldMap.put("unionSupport", 49);
+            fieldMap.put("currentSchema", 50);
         }
     }
 
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java b/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java
index 6c2685b..d621e94 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java
@@ -32959,6 +32959,33 @@ public final class UserProtos {
      * </pre>
      */
     org.apache.drill.exec.proto.UserProtos.UnionSupport getUnionSupport(int index);
+
+    // optional string current_schema = 50;
+    /**
+     * <code>optional string current_schema = 50;</code>
+     *
+     * <pre>
+     * current schema
+     * </pre>
+     */
+    boolean hasCurrentSchema();
+    /**
+     * <code>optional string current_schema = 50;</code>
+     *
+     * <pre>
+     * current schema
+     * </pre>
+     */
+    java.lang.String getCurrentSchema();
+    /**
+     * <code>optional string current_schema = 50;</code>
+     *
+     * <pre>
+     * current schema
+     * </pre>
+     */
+    com.google.protobuf.ByteString
+        getCurrentSchemaBytes();
   }
   /**
    * Protobuf type {@code exec.user.ServerMeta}
@@ -33473,6 +33500,11 @@ public final class UserProtos {
               input.popLimit(oldLimit);
               break;
             }
+            case 402: {
+              bitField1_ |= 0x00000020;
+              currentSchema_ = input.readBytes();
+              break;
+            }
           }
         }
       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -35145,6 +35177,61 @@ public final class UserProtos {
       return unionSupport_.get(index);
     }
 
+    // optional string current_schema = 50;
+    public static final int CURRENT_SCHEMA_FIELD_NUMBER = 50;
+    private java.lang.Object currentSchema_;
+    /**
+     * <code>optional string current_schema = 50;</code>
+     *
+     * <pre>
+     * current schema
+     * </pre>
+     */
+    public boolean hasCurrentSchema() {
+      return ((bitField1_ & 0x00000020) == 0x00000020);
+    }
+    /**
+     * <code>optional string current_schema = 50;</code>
+     *
+     * <pre>
+     * current schema
+     * </pre>
+     */
+    public java.lang.String getCurrentSchema() {
+      java.lang.Object ref = currentSchema_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        if (bs.isValidUtf8()) {
+          currentSchema_ = s;
+        }
+        return s;
+      }
+    }
+    /**
+     * <code>optional string current_schema = 50;</code>
+     *
+     * <pre>
+     * current schema
+     * </pre>
+     */
+    public com.google.protobuf.ByteString
+        getCurrentSchemaBytes() {
+      java.lang.Object ref = currentSchema_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        currentSchema_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
     private void initFields() {
       allTablesSelectable_ = false;
       blobIncludedInMaxRowSize_ = false;
@@ -35195,6 +35282,7 @@ public final class UserProtos {
       tableTerm_ = "";
       transactionSupported_ = false;
       unionSupport_ = java.util.Collections.emptyList();
+      currentSchema_ = "";
     }
     private byte memoizedIsInitialized = -1;
     public final boolean isInitialized() {
@@ -35361,6 +35449,9 @@ public final class UserProtos {
       for (int i = 0; i < unionSupport_.size(); i++) {
         output.writeEnum(49, unionSupport_.get(i).getNumber());
       }
+      if (((bitField1_ & 0x00000020) == 0x00000020)) {
+        output.writeBytes(50, getCurrentSchemaBytes());
+      }
       getUnknownFields().writeTo(output);
     }
 
@@ -35621,6 +35712,10 @@ public final class UserProtos {
         size += dataSize;
         size += 2 * unionSupport_.size();
       }
+      if (((bitField1_ & 0x00000020) == 0x00000020)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(50, getCurrentSchemaBytes());
+      }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
@@ -35840,6 +35935,8 @@ public final class UserProtos {
         bitField1_ = (bitField1_ & ~0x00008000);
         unionSupport_ = java.util.Collections.emptyList();
         bitField1_ = (bitField1_ & ~0x00010000);
+        currentSchema_ = "";
+        bitField1_ = (bitField1_ & ~0x00020000);
         return this;
       }
 
@@ -36087,6 +36184,10 @@ public final class UserProtos {
           bitField1_ = (bitField1_ & ~0x00010000);
         }
         result.unionSupport_ = unionSupport_;
+        if (((from_bitField1_ & 0x00020000) == 0x00020000)) {
+          to_bitField1_ |= 0x00000020;
+        }
+        result.currentSchema_ = currentSchema_;
         result.bitField0_ = to_bitField0_;
         result.bitField1_ = to_bitField1_;
         onBuilt();
@@ -36365,6 +36466,11 @@ public final class UserProtos {
           }
           onChanged();
         }
+        if (other.hasCurrentSchema()) {
+          bitField1_ |= 0x00020000;
+          currentSchema_ = other.currentSchema_;
+          onChanged();
+        }
         this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
@@ -40127,6 +40233,104 @@ public final class UserProtos {
         return this;
       }
 
+      // optional string current_schema = 50;
+      private java.lang.Object currentSchema_ = "";
+      /**
+       * <code>optional string current_schema = 50;</code>
+       *
+       * <pre>
+       * current schema
+       * </pre>
+       */
+      public boolean hasCurrentSchema() {
+        return ((bitField1_ & 0x00020000) == 0x00020000);
+      }
+      /**
+       * <code>optional string current_schema = 50;</code>
+       *
+       * <pre>
+       * current schema
+       * </pre>
+       */
+      public java.lang.String getCurrentSchema() {
+        java.lang.Object ref = currentSchema_;
+        if (!(ref instanceof java.lang.String)) {
+          java.lang.String s = ((com.google.protobuf.ByteString) ref)
+              .toStringUtf8();
+          currentSchema_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>optional string current_schema = 50;</code>
+       *
+       * <pre>
+       * current schema
+       * </pre>
+       */
+      public com.google.protobuf.ByteString
+          getCurrentSchemaBytes() {
+        java.lang.Object ref = currentSchema_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          currentSchema_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>optional string current_schema = 50;</code>
+       *
+       * <pre>
+       * current schema
+       * </pre>
+       */
+      public Builder setCurrentSchema(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField1_ |= 0x00020000;
+        currentSchema_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional string current_schema = 50;</code>
+       *
+       * <pre>
+       * current schema
+       * </pre>
+       */
+      public Builder clearCurrentSchema() {
+        bitField1_ = (bitField1_ & ~0x00020000);
+        currentSchema_ = getDefaultInstance().getCurrentSchema();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional string current_schema = 50;</code>
+       *
+       * <pre>
+       * current schema
+       * </pre>
+       */
+      public Builder setCurrentSchemaBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField1_ |= 0x00020000;
+        currentSchema_ = value;
+        onChanged();
+        return this;
+      }
+
       // @@protoc_insertion_point(builder_scope:exec.user.ServerMeta)
     }
 
@@ -41921,7 +42125,7 @@ public final class UserProtos {
       "verMetaResp\022(\n\006status\030\001 \001(\0162\030.exec.user." +
       "RequestStatus\022*\n\013server_meta\030\002 \001(\0132\025.exe" +
       "c.user.ServerMeta\022(\n\005error\030\003 \001(\0132\031.exec." +
-      "shared.DrillPBError\"\377\r\n\nServerMeta\022\035\n\025al" +
+      "shared.DrillPBError\"\227\016\n\nServerMeta\022\035\n\025al" +
       "l_tables_selectable\030\001 \001(\010\022%\n\035blob_includ" +
       "ed_in_max_row_size\030\002 \001(\010\022\030\n\020catalog_at_s" +
       "tart\030\003 \001(\010\022\031\n\021catalog_separator\030\004 \001(\t\022\024\n" +
@@ -41966,70 +42170,70 @@ public final class UserProtos {
       "ySupport\022\030\n\020system_functions\030. \003(\t\022\022\n\nta" +
       "ble_term\030/ \001(\t\022\035\n\025transaction_supported\030" +
       "0 \001(\010\022.\n\runion_support\0301 \003(\0162\027.exec.user" +
-      ".UnionSupport\"\353\001\n\010RunQuery\0221\n\014results_mo",
-      "de\030\001 \001(\0162\033.exec.user.QueryResultsMode\022$\n" +
-      "\004type\030\002 \001(\0162\026.exec.shared.QueryType\022\014\n\004p" +
-      "lan\030\003 \001(\t\0221\n\tfragments\030\004 \003(\0132\036.exec.bit." +
-      "control.PlanFragment\022E\n\031prepared_stateme" +
-      "nt_handle\030\005 \001(\0132\".exec.user.PreparedStat" +
-      "ementHandle*\320\003\n\007RpcType\022\r\n\tHANDSHAKE\020\000\022\007" +
-      "\n\003ACK\020\001\022\013\n\007GOODBYE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014C" +
-      "ANCEL_QUERY\020\004\022\023\n\017REQUEST_RESULTS\020\005\022\027\n\023RE" +
-      "SUME_PAUSED_QUERY\020\013\022\034\n\030GET_QUERY_PLAN_FR" +
-      "AGMENTS\020\014\022\020\n\014GET_CATALOGS\020\016\022\017\n\013GET_SCHEM",
-      "AS\020\017\022\016\n\nGET_TABLES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n" +
-      "\031CREATE_PREPARED_STATEMENT\020\026\022\023\n\017GET_SERV" +
-      "ER_META\020\010\022\016\n\nQUERY_DATA\020\006\022\020\n\014QUERY_HANDL" +
-      "E\020\007\022\030\n\024QUERY_PLAN_FRAGMENTS\020\r\022\014\n\010CATALOG" +
-      "S\020\022\022\013\n\007SCHEMAS\020\023\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020" +
-      "\025\022\026\n\022PREPARED_STATEMENT\020\027\022\017\n\013SERVER_META" +
-      "\020\t\022\020\n\014QUERY_RESULT\020\n\022\020\n\014SASL_MESSAGE\020\030*H" +
-      "\n\013SaslSupport\022\030\n\024UNKNOWN_SASL_SUPPORT\020\000\022" +
-      "\r\n\tSASL_AUTH\020\001\022\020\n\014SASL_PRIVACY\020\002*#\n\020Quer" +
-      "yResultsMode\022\017\n\013STREAM_FULL\020\001*q\n\017Handsha",
-      "keStatus\022\013\n\007SUCCESS\020\001\022\030\n\024RPC_VERSION_MIS" +
-      "MATCH\020\002\022\017\n\013AUTH_FAILED\020\003\022\023\n\017UNKNOWN_FAIL" +
-      "URE\020\004\022\021\n\rAUTH_REQUIRED\020\005*D\n\rRequestStatu" +
-      "s\022\022\n\016UNKNOWN_STATUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020" +
-      "\002\022\013\n\007TIMEOUT\020\003*Y\n\023ColumnSearchability\022\031\n" +
-      "\025UNKNOWN_SEARCHABILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CH" +
-      "AR\020\002\022\n\n\006NUMBER\020\003\022\007\n\003ALL\020\004*K\n\022ColumnUpdat" +
-      "ability\022\030\n\024UNKNOWN_UPDATABILITY\020\000\022\r\n\tREA" +
-      "D_ONLY\020\001\022\014\n\010WRITABLE\020\002*1\n\016CollateSupport" +
-      "\022\016\n\nCS_UNKNOWN\020\000\022\017\n\013CS_GROUP_BY\020\001*J\n\027Cor",
-      "relationNamesSupport\022\013\n\007CN_NONE\020\001\022\026\n\022CN_" +
-      "DIFFERENT_NAMES\020\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTi" +
-      "meLiteralsSupport\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_" +
-      "DATE\020\001\022\013\n\007DL_TIME\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n" +
-      "\020DL_INTERVAL_YEAR\020\004\022\025\n\021DL_INTERVAL_MONTH" +
-      "\020\005\022\023\n\017DL_INTERVAL_DAY\020\006\022\024\n\020DL_INTERVAL_H" +
-      "OUR\020\007\022\026\n\022DL_INTERVAL_MINUTE\020\010\022\026\n\022DL_INTE" +
-      "RVAL_SECOND\020\t\022\035\n\031DL_INTERVAL_YEAR_TO_MON" +
-      "TH\020\n\022\033\n\027DL_INTERVAL_DAY_TO_HOUR\020\013\022\035\n\031DL_" +
-      "INTERVAL_DAY_TO_MINUTE\020\014\022\035\n\031DL_INTERVAL_",
-      "DAY_TO_SECOND\020\r\022\036\n\032DL_INTERVAL_HOUR_TO_M" +
-      "INUTE\020\016\022\036\n\032DL_INTERVAL_HOUR_TO_SECOND\020\017\022" +
-      " \n\034DL_INTERVAL_MINUTE_TO_SECOND\020\020*Y\n\016Gro" +
-      "upBySupport\022\013\n\007GB_NONE\020\001\022\022\n\016GB_SELECT_ON" +
-      "LY\020\002\022\024\n\020GB_BEYOND_SELECT\020\003\022\020\n\014GB_UNRELAT" +
-      "ED\020\004*x\n\020IdentifierCasing\022\016\n\nIC_UNKNOWN\020\000" +
-      "\022\023\n\017IC_STORES_LOWER\020\001\022\023\n\017IC_STORES_MIXED" +
-      "\020\002\022\023\n\017IC_STORES_UPPER\020\003\022\025\n\021IC_SUPPORTS_M" +
-      "IXED\020\004*X\n\rNullCollation\022\016\n\nNC_UNKNOWN\020\000\022" +
-      "\017\n\013NC_AT_START\020\001\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HI",
-      "GH\020\003\022\n\n\006NC_LOW\020\004*E\n\016OrderBySupport\022\016\n\nOB" +
-      "_UNKNOWN\020\000\022\020\n\014OB_UNRELATED\020\001\022\021\n\rOB_EXPRE" +
-      "SSION\020\002*\226\001\n\020OuterJoinSupport\022\016\n\nOJ_UNKNO" +
-      "WN\020\000\022\013\n\007OJ_LEFT\020\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FU" +
-      "LL\020\003\022\r\n\tOJ_NESTED\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022" +
-      "\014\n\010OJ_INNER\020\006\022\031\n\025OJ_ALL_COMPARISON_OPS\020\007" +
-      "*\204\001\n\017SubQuerySupport\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\r" +
-      "SQ_CORRELATED\020\001\022\024\n\020SQ_IN_COMPARISON\020\002\022\020\n" +
-      "\014SQ_IN_EXISTS\020\003\022\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_" +
-      "IN_QUANTIFIED\020\005*;\n\014UnionSupport\022\r\n\tU_UNK",
-      "NOWN\020\000\022\013\n\007U_UNION\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033" +
-      "org.apache.drill.exec.protoB\nUserProtosH" +
-      "\001"
+      ".UnionSupport\022\026\n\016current_schema\0302 \001(\t\"\353\001",
+      "\n\010RunQuery\0221\n\014results_mode\030\001 \001(\0162\033.exec." +
+      "user.QueryResultsMode\022$\n\004type\030\002 \001(\0162\026.ex" +
+      "ec.shared.QueryType\022\014\n\004plan\030\003 \001(\t\0221\n\tfra" +
+      "gments\030\004 \003(\0132\036.exec.bit.control.PlanFrag" +
+      "ment\022E\n\031prepared_statement_handle\030\005 \001(\0132" +
+      "\".exec.user.PreparedStatementHandle*\320\003\n\007" +
+      "RpcType\022\r\n\tHANDSHAKE\020\000\022\007\n\003ACK\020\001\022\013\n\007GOODB" +
+      "YE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014CANCEL_QUERY\020\004\022\023\n" +
+      "\017REQUEST_RESULTS\020\005\022\027\n\023RESUME_PAUSED_QUER" +
+      "Y\020\013\022\034\n\030GET_QUERY_PLAN_FRAGMENTS\020\014\022\020\n\014GET",
+      "_CATALOGS\020\016\022\017\n\013GET_SCHEMAS\020\017\022\016\n\nGET_TABL" +
+      "ES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n\031CREATE_PREPARED" +
+      "_STATEMENT\020\026\022\023\n\017GET_SERVER_META\020\010\022\016\n\nQUE" +
+      "RY_DATA\020\006\022\020\n\014QUERY_HANDLE\020\007\022\030\n\024QUERY_PLA" +
+      "N_FRAGMENTS\020\r\022\014\n\010CATALOGS\020\022\022\013\n\007SCHEMAS\020\023" +
+      "\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020\025\022\026\n\022PREPARED_ST" +
+      "ATEMENT\020\027\022\017\n\013SERVER_META\020\t\022\020\n\014QUERY_RESU" +
+      "LT\020\n\022\020\n\014SASL_MESSAGE\020\030*H\n\013SaslSupport\022\030\n" +
+      "\024UNKNOWN_SASL_SUPPORT\020\000\022\r\n\tSASL_AUTH\020\001\022\020" +
+      "\n\014SASL_PRIVACY\020\002*#\n\020QueryResultsMode\022\017\n\013",
+      "STREAM_FULL\020\001*q\n\017HandshakeStatus\022\013\n\007SUCC" +
+      "ESS\020\001\022\030\n\024RPC_VERSION_MISMATCH\020\002\022\017\n\013AUTH_" +
+      "FAILED\020\003\022\023\n\017UNKNOWN_FAILURE\020\004\022\021\n\rAUTH_RE" +
+      "QUIRED\020\005*D\n\rRequestStatus\022\022\n\016UNKNOWN_STA" +
+      "TUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020\002\022\013\n\007TIMEOUT\020\003*Y" +
+      "\n\023ColumnSearchability\022\031\n\025UNKNOWN_SEARCHA" +
+      "BILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CHAR\020\002\022\n\n\006NUMBER\020\003" +
+      "\022\007\n\003ALL\020\004*K\n\022ColumnUpdatability\022\030\n\024UNKNO" +
+      "WN_UPDATABILITY\020\000\022\r\n\tREAD_ONLY\020\001\022\014\n\010WRIT" +
+      "ABLE\020\002*1\n\016CollateSupport\022\016\n\nCS_UNKNOWN\020\000",
+      "\022\017\n\013CS_GROUP_BY\020\001*J\n\027CorrelationNamesSup" +
+      "port\022\013\n\007CN_NONE\020\001\022\026\n\022CN_DIFFERENT_NAMES\020" +
+      "\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTimeLiteralsSuppor" +
+      "t\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_DATE\020\001\022\013\n\007DL_TIM" +
+      "E\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n\020DL_INTERVAL_YEA" +
+      "R\020\004\022\025\n\021DL_INTERVAL_MONTH\020\005\022\023\n\017DL_INTERVA" +
+      "L_DAY\020\006\022\024\n\020DL_INTERVAL_HOUR\020\007\022\026\n\022DL_INTE" +
+      "RVAL_MINUTE\020\010\022\026\n\022DL_INTERVAL_SECOND\020\t\022\035\n" +
+      "\031DL_INTERVAL_YEAR_TO_MONTH\020\n\022\033\n\027DL_INTER" +
+      "VAL_DAY_TO_HOUR\020\013\022\035\n\031DL_INTERVAL_DAY_TO_",
+      "MINUTE\020\014\022\035\n\031DL_INTERVAL_DAY_TO_SECOND\020\r\022" +
+      "\036\n\032DL_INTERVAL_HOUR_TO_MINUTE\020\016\022\036\n\032DL_IN" +
+      "TERVAL_HOUR_TO_SECOND\020\017\022 \n\034DL_INTERVAL_M" +
+      "INUTE_TO_SECOND\020\020*Y\n\016GroupBySupport\022\013\n\007G" +
+      "B_NONE\020\001\022\022\n\016GB_SELECT_ONLY\020\002\022\024\n\020GB_BEYON" +
+      "D_SELECT\020\003\022\020\n\014GB_UNRELATED\020\004*x\n\020Identifi" +
+      "erCasing\022\016\n\nIC_UNKNOWN\020\000\022\023\n\017IC_STORES_LO" +
+      "WER\020\001\022\023\n\017IC_STORES_MIXED\020\002\022\023\n\017IC_STORES_" +
+      "UPPER\020\003\022\025\n\021IC_SUPPORTS_MIXED\020\004*X\n\rNullCo" +
+      "llation\022\016\n\nNC_UNKNOWN\020\000\022\017\n\013NC_AT_START\020\001",
+      "\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HIGH\020\003\022\n\n\006NC_LOW\020\004" +
+      "*E\n\016OrderBySupport\022\016\n\nOB_UNKNOWN\020\000\022\020\n\014OB" +
+      "_UNRELATED\020\001\022\021\n\rOB_EXPRESSION\020\002*\226\001\n\020Oute" +
+      "rJoinSupport\022\016\n\nOJ_UNKNOWN\020\000\022\013\n\007OJ_LEFT\020" +
+      "\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FULL\020\003\022\r\n\tOJ_NESTE" +
+      "D\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022\014\n\010OJ_INNER\020\006\022\031\n" +
+      "\025OJ_ALL_COMPARISON_OPS\020\007*\204\001\n\017SubQuerySup" +
+      "port\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\rSQ_CORRELATED\020\001\022" +
+      "\024\n\020SQ_IN_COMPARISON\020\002\022\020\n\014SQ_IN_EXISTS\020\003\022" +
+      "\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_IN_QUANTIFIED\020\005*",
+      ";\n\014UnionSupport\022\r\n\tU_UNKNOWN\020\000\022\013\n\007U_UNIO" +
+      "N\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033org.apache.drill" +
+      ".exec.protoB\nUserProtosH\001"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -42215,7 +42419,7 @@ public final class UserProtos {
           internal_static_exec_user_ServerMeta_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_exec_user_ServerMeta_descriptor,
-              new java.lang.String[] { "AllTablesSelectable", "BlobIncludedInMaxRowSize", "CatalogAtStart", "CatalogSeparator", "CatalogTerm", "CollateSupport", "ColumnAliasingSupported", "ConvertSupport", "CorrelationNamesSupport", "DateTimeFunctions", "DateTimeLiteralsSupport", "GroupBySupport", "IdentifierCasing", "IdentifierQuoteString", "LikeEscapeClauseSupported", "MaxBinaryLiteralLength", "MaxCatalogNameLength", "MaxCharLiteralLength", "MaxColumnNameLength", "MaxColumnsInGroupBy", [...]
+              new java.lang.String[] { "AllTablesSelectable", "BlobIncludedInMaxRowSize", "CatalogAtStart", "CatalogSeparator", "CatalogTerm", "CollateSupport", "ColumnAliasingSupported", "ConvertSupport", "CorrelationNamesSupport", "DateTimeFunctions", "DateTimeLiteralsSupport", "GroupBySupport", "IdentifierCasing", "IdentifierQuoteString", "LikeEscapeClauseSupported", "MaxBinaryLiteralLength", "MaxCatalogNameLength", "MaxCharLiteralLength", "MaxColumnNameLength", "MaxColumnsInGroupBy", [...]
           internal_static_exec_user_RunQuery_descriptor =
             getDescriptor().getMessageTypes().get(30);
           internal_static_exec_user_RunQuery_fieldAccessorTable = new
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java b/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java
index f05783a..d5032f9 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java
@@ -98,6 +98,7 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc
     private String tableTerm;
     private Boolean transactionSupported;
     private List<UnionSupport> unionSupport;
+    private String currentSchema;
 
     public ServerMeta()
     {
@@ -743,6 +744,19 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc
         return this;
     }
 
+    // currentSchema
+
+    public String getCurrentSchema()
+    {
+        return currentSchema;
+    }
+
+    public ServerMeta setCurrentSchema(String currentSchema)
+    {
+        this.currentSchema = currentSchema;
+        return this;
+    }
+
     // java serialization
 
     public void readExternal(ObjectInput in) throws IOException
@@ -969,6 +983,9 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc
                         message.unionSupport = new ArrayList<UnionSupport>();
                     message.unionSupport.add(UnionSupport.valueOf(input.readEnum()));
                     break;
+                case 50:
+                    message.currentSchema = input.readString();
+                    break;
                 default:
                     input.handleUnknownField(number, this);
             }   
@@ -1197,6 +1214,9 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc
                     output.writeEnum(49, unionSupport.number, true);
             }
         }
+
+        if(message.currentSchema != null)
+            output.writeString(50, message.currentSchema, false);
     }
 
     public String getFieldName(int number)
@@ -1252,6 +1272,7 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc
             case 47: return "tableTerm";
             case 48: return "transactionSupported";
             case 49: return "unionSupport";
+            case 50: return "currentSchema";
             default: return null;
         }
     }
@@ -1314,6 +1335,7 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc
         __fieldMap.put("tableTerm", 47);
         __fieldMap.put("transactionSupported", 48);
         __fieldMap.put("unionSupport", 49);
+        __fieldMap.put("currentSchema", 50);
     }
     
 }
diff --git a/protocol/src/main/protobuf/User.proto b/protocol/src/main/protobuf/User.proto
index 2af8b26..8c1a3a2 100644
--- a/protocol/src/main/protobuf/User.proto
+++ b/protocol/src/main/protobuf/User.proto
@@ -652,6 +652,8 @@ message ServerMeta {
     optional bool                       transaction_supported = 48;
     // UNION support
     repeated UnionSupport               union_support = 49;
+    // current schema
+    optional string                     current_schema = 50;
 }
 
 /*


[drill] 03/05: DRILL-6939: Indicate when a query is submitted and is in progress

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

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

commit 5c90032503dbdaa75e71a4a22dd150218960145a
Author: Kunal Khatua <kk...@maprtech.com>
AuthorDate: Thu Jan 3 10:27:57 2019 -0800

    DRILL-6939: Indicate when a query is submitted and is in progress
    
    On query submission, a modal popup blocks further interaction until the result of the query are available.
    Since the Query ID is not available at this point, the only way to cancel a running query is to navigate to it via the `/profiles` tab. For this, the modal allows a button to pop out to this tab without closing the current window which is waiting for the result-set.
    [Update] Shared running query modal introduced
    closes #1592
---
 .../src/main/resources/rest/profile/profile.ftl    |   3 ++
 .../src/main/resources/rest/query/query.ftl        |   2 +
 .../src/main/resources/rest/runningQuery.ftl       |  44 +++++++++++++++++++++
 .../src/main/resources/rest/static/img/loader.gif  | Bin 0 -> 26758 bytes
 .../resources/rest/static/js/querySubmission.js    |  31 ++++++++++++++-
 5 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/exec/java-exec/src/main/resources/rest/profile/profile.ftl b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
index ab245c7..e432e20 100644
--- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
@@ -179,6 +179,9 @@ table.sortable thead .sorting_desc { background-image: url("/static/img/black-de
             </button>
           </form>
       </p>
+
+<#include "*/runningQuery.ftl">
+
       <p>
       <form action="/profiles/cancel/${model.queryId}" method="GET">
         <div class="form-group">
diff --git a/exec/java-exec/src/main/resources/rest/query/query.ftl b/exec/java-exec/src/main/resources/rest/query/query.ftl
index 3477f94..38ed7c9 100644
--- a/exec/java-exec/src/main/resources/rest/query/query.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/query.ftl
@@ -39,6 +39,8 @@
     Sample SQL query: <strong>SELECT * FROM cp.`employee.json` LIMIT 20</strong>
   </div>
 
+<#include "*/runningQuery.ftl">
+
   <#if model?? && model>
      <div class="form-group">
        <label for="userName">User Name</label>
diff --git a/exec/java-exec/src/main/resources/rest/runningQuery.ftl b/exec/java-exec/src/main/resources/rest/runningQuery.ftl
new file mode 100644
index 0000000..7978cf5
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/runningQuery.ftl
@@ -0,0 +1,44 @@
+<#--
+
+    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.
+
+-->
+  <!-- Loading Modal -->
+  <div class="modal fade" id="queryLoadingModal" role="dialog"  data-backdrop="static" data-keyboard="false">
+    <div class="modal-dialog">
+      <!-- Modal content-->
+      <div class="modal-content">
+        <div class="modal-header">
+          <h4 class="modal-title" id="cancelTitle">Query Submitted</h4>
+        </div>
+        <div class="modal-body" style="line-height:3">
+            <table border="0px" width="100%"><tr>
+                <td align="center" style="font-size:125%">Waiting for results... (This may take some time) <br>Please don't close this window</td>
+                <td align="right"><img src="/static/img/loader.gif"></td>
+            </tr></table>
+        </div>
+        <div class="modal-footer">
+        <table border="0px" width="100%"><tr>
+        <td align="left" id="stopWatch">Elapsed Time: 00:00</td><td align="right">
+          <button type="button" class="btn btn-default" title="Check profiles in new tab" onclick="window.open(&#39;/profiles&#39;)">Check Status <span class="glyphicon glyphicon-new-window"></span></button>
+          </td>
+          </tr>
+          </table>
+        </div>
+      </div>
+    </div>
+  </div>
\ No newline at end of file
diff --git a/exec/java-exec/src/main/resources/rest/static/img/loader.gif b/exec/java-exec/src/main/resources/rest/static/img/loader.gif
new file mode 100644
index 0000000..0b0294b
Binary files /dev/null and b/exec/java-exec/src/main/resources/rest/static/img/loader.gif differ
diff --git a/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js b/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
index d278517..e62cc8f 100644
--- a/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
+++ b/exec/java-exec/src/main/resources/rest/static/js/querySubmission.js
@@ -11,10 +11,36 @@
  *  language governing permissions and limitations under the License.
  */
 var userName = null;
+//Elements for Timer in LoadingModal
+var elapsedTime = 0;
+var delay = 1000; //msec
+var timeTracker = null; //Handle for stopping watch
+
+//Show cancellation status
+function popupAndWait() {
+  elapsedTime=0; //Init
+  $("#queryLoadingModal").modal("show");
+  var stopWatchElem = $('#stopWatch'); //Get handle on time progress elem within Modal
+  //Timer updating
+  timeTracker = setInterval(function() {
+    elapsedTime = elapsedTime + delay/1000;
+    let time = elapsedTime;
+    let minutes = Math.floor(time / 60);
+    let seconds = time - minutes * 60;
+    let prettyTime = ("0" + minutes).slice(-2)+':'+ ("0" + seconds).slice(-2);
+    stopWatchElem.text('Elapsed Time : ' + prettyTime);
+  }, delay);
+}
+
+//Close the cancellation status popup
+function closePopup() {
+  clearInterval(timeTracker);
+  $("#queryLoadingModal").modal("hide");
+}
 
 //Submit query with username
 function doSubmitQueryWithUserName() {
-    userName = document.getElementById("userName").value;
+    var userName = document.getElementById("userName").value;
     if (!userName.trim()) {
         alert("Please fill in User Name field");
         return;
@@ -24,6 +50,7 @@ function doSubmitQueryWithUserName() {
 
 //Submit Query (used if impersonation is not enabled)
 function submitQuery() {
+    popupAndWait();
     //Submit query
     $.ajax({
         type: "POST",
@@ -35,11 +62,13 @@ function submitQuery() {
         url: "/query",
         data: $("#queryForm").serializeArray(),
         success: function (response) {
+            closePopup();
             var newDoc = document.open("text/html", "replace");
             newDoc.write(response);
             newDoc.close();
         },
         error: function (request, textStatus, errorThrown) {
+            closePopup();
             alert(errorThrown);
         }
     });