drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [2/6] drill git commit: DRILL-1769: Fix issue where option manager not holding settings.
Date Mon, 08 Dec 2014 15:55:35 GMT
DRILL-1769: Fix issue where option manager not holding settings.


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

Branch: refs/heads/master
Commit: bd3e9138aa4ffe38269c09aea740f08bd6b41355
Parents: dcc9bb2
Author: Jacques Nadeau <jacques@apache.org>
Authored: Sun Dec 7 22:11:49 2014 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Dec 7 22:37:17 2014 -0800

----------------------------------------------------------------------
 .../server/options/FallbackOptionManager.java   | 10 +++--
 .../server/options/InMemoryOptionManager.java   |  5 +++
 .../drill/exec/server/options/OptionList.java   |  4 ++
 .../exec/server/options/QueryOptionManager.java |  9 ++++
 .../drill/exec/store/sys/SystemTablePlugin.java |  1 -
 .../java/org/apache/drill/BaseTestQuery.java    |  8 ++++
 .../test/java/org/apache/drill/TestBuilder.java |  8 ++++
 .../drill/exec/store/sys/TestSystemTable.java   | 47 ++++++++++++++++++++
 8 files changed, 87 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
index 1a5e137..f515f8e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
@@ -29,8 +29,7 @@ import com.google.common.collect.Maps;
 public abstract class FallbackOptionManager implements OptionManager{
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FallbackOptionManager.class);
 
-  private Map<String, OptionValue> options = Maps.newConcurrentMap();
-  private OptionManager fallback;
+  protected OptionManager fallback;
 
   public FallbackOptionManager(OptionManager fallback) {
     super();
@@ -39,7 +38,7 @@ public abstract class FallbackOptionManager implements OptionManager{
 
   @Override
   public Iterator<OptionValue> iterator() {
-    return Iterables.concat(fallback, options.values()).iterator();
+    return Iterables.concat(fallback, optionIterable()).iterator();
   }
 
   @Override
@@ -52,6 +51,7 @@ public abstract class FallbackOptionManager implements OptionManager{
     }
   }
 
+  abstract Iterable<OptionValue> optionIterable();
   abstract OptionValue getLocalOption(String name);
   abstract boolean setLocalOption(OptionValue value);
 
@@ -71,6 +71,8 @@ public abstract class FallbackOptionManager implements OptionManager{
   private void setValidatedOption(OptionValue value) {
     if (!setLocalOption(value)) {
       fallback.setOption(value);
+    }else{
+      setLocalOption(value);
     }
   }
 
@@ -88,7 +90,7 @@ public abstract class FallbackOptionManager implements OptionManager{
   @Override
   public OptionList getOptionList() {
     OptionList list = new OptionList();
-    for (OptionValue o : options.values()) {
+    for (OptionValue o : optionIterable()) {
       list.add(o);
     }
     return list;

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/InMemoryOptionManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/InMemoryOptionManager.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/InMemoryOptionManager.java
index 59411ce..b033a03 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/InMemoryOptionManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/InMemoryOptionManager.java
@@ -45,6 +45,11 @@ public abstract class InMemoryOptionManager extends FallbackOptionManager
{
 
   }
 
+  @Override
+  Iterable<OptionValue> optionIterable() {
+    return options.values();
+  }
+
   abstract boolean supportsOption(OptionValue value);
 
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionList.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionList.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionList.java
index b6d4f8c..8851e1a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionList.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionList.java
@@ -20,4 +20,8 @@ package org.apache.drill.exec.server.options;
 import java.util.ArrayList;
 
 public class OptionList extends ArrayList<OptionValue>{
+
+  public void merge(OptionList list){
+    this.addAll(list);
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/QueryOptionManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/QueryOptionManager.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/QueryOptionManager.java
index d04b654..fa9223d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/QueryOptionManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/QueryOptionManager.java
@@ -28,6 +28,15 @@ public class QueryOptionManager extends InMemoryOptionManager {
     super(sessionOptions, new HashMap<String, OptionValue>());
   }
 
+
+  @Override
+  public OptionList getOptionList() {
+    OptionList list = super.getOptionList();
+    list.merge(fallback.getOptionList());
+    return list;
+  }
+
+
   @Override
   boolean supportsOption(OptionValue value) {
     return value.type == OptionType.QUERY;

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
index 5a25724..2c70fd4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
@@ -71,7 +71,6 @@ public class SystemTablePlugin extends AbstractStoragePlugin{
     case DRILLBITS:
       return new DrillbitIterator(context);
     case OPTION:
-
       return Iterables.concat((Iterable<Object>)(Object) new DrillConfigIterator(context.getConfig()),
//
           context.getOptions()).iterator();
     default:

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java b/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
index 782fbe7..f75a574 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
@@ -137,6 +137,10 @@ public class BaseTestQuery extends ExecTest{
     return allocator;
   }
 
+  public TestBuilder newTest() {
+    return testBuilder();
+  }
+
   public TestBuilder testBuilder() {
     return new TestBuilder(allocator);
   }
@@ -207,6 +211,10 @@ public class BaseTestQuery extends ExecTest{
     }
   }
 
+  public static void test(String query, Object... args) throws Exception {
+    test(String.format(query, args));
+  }
+
   public static void test(String query) throws Exception{
     query = query.replaceAll(Pattern.quote("${WORKING_PATH}"), TestTools.getWorkingPath());
     String[] queries = query.split(";");

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java b/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
index 63de112..99cf707 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
@@ -119,12 +119,20 @@ public class TestBuilder {
         getValidationQueryType(), ordered, approximateEquality, highPerformanceComparison,
baselineRecords);
   }
 
+  public void go() throws Exception {
+    build().run();
+  }
+
   public TestBuilder sqlQuery(String query) {
     this.query = query.replaceAll(Pattern.quote("${WORKING_PATH}"), TestTools.getWorkingPath());
     this.queryType = UserBitShared.QueryType.SQL;
     return this;
   }
 
+  public TestBuilder sqlQuery(String query, Object... replacements) {
+    return sqlQuery(String.format(query, replacements));
+  }
+
   public TestBuilder sqlQueryFromFile(String queryFile) throws IOException {
     String query = BaseTestQuery.getFile(queryFile);
     this.query = query;

http://git-wip-us.apache.org/repos/asf/drill/blob/bd3e9138/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestSystemTable.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestSystemTable.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestSystemTable.java
new file mode 100644
index 0000000..c1803bc
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestSystemTable.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.store.sys;
+
+import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.ExecConstants;
+import org.junit.Test;
+
+public class TestSystemTable extends BaseTestQuery {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSystemTable.class);
+
+  @Test
+  public void alterSessionOption() throws Exception {
+
+    newTest() //
+      .sqlQuery("select bool_val as bool from sys.options where name = '%s' order by type
desc", ExecConstants.JSON_ALL_TEXT_MODE)
+      .baselineColumns("bool")
+      .ordered()
+      .baselineValues(false)
+      .go();
+
+    test("alter session set `%s` = true", ExecConstants.JSON_ALL_TEXT_MODE);
+
+    newTest() //
+      .sqlQuery("select bool_val as bool from sys.options where name = '%s' order by type
desc ", ExecConstants.JSON_ALL_TEXT_MODE)
+      .baselineColumns("bool")
+      .ordered()
+      .baselineValues(false)
+      .baselineValues(true)
+      .go();
+  }
+}


Mime
View raw message