Repository: drill
Updated Branches:
  refs/heads/master 9baec8a89 -> cc7bc9535


DRILL-2304: Manage options with lowercase names

This closes #90

Major refactoring:
+ Removed unnecessary methods from OptionManagers, and refactored 
implementations
+ Removed OptionAdmin interface, which was a delegate to validators

Other fixes:
+ Added CaseInsensitiveMap
+ Moved OptionValue creation from TypeValidators to SetOptionHandler
+ Fixed error message in BaseOptionManager
+ Added documentation for all OptionManagers, and OptionValidator

DRILL-2304: Addressing Jason's review comments (1)

+ Use generic Map rather than CaseInsensitiveMap for member variables and 
parameters
+ SessionOptionManager should use a ConcurrentHashMap


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

Branch: refs/heads/master
Commit: cc7bc9535bddc08a4d9fee1a35284ad16b5a14c9
Parents: 9baec8a
Author: Sudheesh Katkam <[email protected]>
Authored: Wed Jul 22 16:32:02 2015 -0700
Committer: Jason Altekruse <[email protected]>
Committed: Fri Sep 4 11:33:21 2015 -0700

----------------------------------------------------------------------
 .../drill/common/map/CaseInsensitiveMap.java    | 145 ++++++++++++++
 .../common/map/TestCaseInsensitiveMap.java      |  69 +++++++
 .../planner/sql/handlers/SetOptionHandler.java  |  45 ++++-
 .../exec/server/options/BaseOptionManager.java  |   4 +-
 .../server/options/FallbackOptionManager.java   |  81 ++++----
 .../server/options/FragmentOptionManager.java   |  24 +--
 .../server/options/InMemoryOptionManager.java   |  28 ++-
 .../exec/server/options/OptionManager.java      |  79 ++++++--
 .../exec/server/options/OptionValidator.java    |  39 ++--
 .../exec/server/options/QueryOptionManager.java |  14 +-
 .../server/options/SessionOptionManager.java    |  34 ++--
 .../server/options/SystemOptionManager.java     | 195 ++++++++-----------
 .../exec/server/options/TypeValidators.java     |  50 -----
 .../drill/exec/store/sys/OptionIterator.java    |   5 +-
 .../exec/testing/ControlsInjectionUtil.java     |   3 +-
 15 files changed, 525 insertions(+), 290 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/common/src/main/java/org/apache/drill/common/map/CaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git 
a/common/src/main/java/org/apache/drill/common/map/CaseInsensitiveMap.java 
b/common/src/main/java/org/apache/drill/common/map/CaseInsensitiveMap.java
new file mode 100644
index 0000000..e96a20d
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/map/CaseInsensitiveMap.java
@@ -0,0 +1,145 @@
+/**
+ * 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.common.map;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A special type of {@link Map} with {@link String}s as keys, and the case of 
a key is ignored for operations involving
+ * keys like {@link #put}, {@link #get}, etc. The keys are stored and 
retrieved in lower case. Use the static factory
+ * methods to create instances of this class (e.g. {@link #newConcurrentMap}).
+ *
+ * @param <VALUE> the type of values to be stored in the map
+ */
+public class CaseInsensitiveMap<VALUE> implements Map<String, VALUE> {
+
+  /**
+   * Returns a new instance of {@link java.util.concurrent.ConcurrentMap} with 
key case-insensitivity. See
+   * {@link java.util.concurrent.ConcurrentMap}.
+   *
+   * @param <VALUE> type of values to be stored in the map
+   * @return key case-insensitive concurrent map
+   */
+  public static <VALUE> CaseInsensitiveMap<VALUE> newConcurrentMap() {
+    return new CaseInsensitiveMap<>(Maps.<String, VALUE>newConcurrentMap());
+  }
+
+  /**
+   * Returns a new instance of {@link java.util.HashMap} with key 
case-insensitivity. See {@link java.util.HashMap}.
+   *
+   * @param <VALUE> type of values to be stored in the map
+   * @return key case-insensitive hash map
+   */
+  public static <VALUE> CaseInsensitiveMap<VALUE> newHashMap() {
+    return new CaseInsensitiveMap<>(Maps.<String, VALUE>newHashMap());
+  }
+
+  /**
+   * Returns a new instance of {@link ImmutableMap} with key 
case-insensitivity. This map is built from the given
+   * map. See {@link ImmutableMap}.
+   *
+   * @param map map to copy from
+   * @param <VALUE> type of values to be stored in the map
+   * @return key case-insensitive immutable map
+   */
+  public static <VALUE> CaseInsensitiveMap<VALUE> newImmutableMap(final Map<? 
extends String, ? extends VALUE> map) {
+    final ImmutableMap.Builder<String, VALUE> builder = ImmutableMap.builder();
+    for (final Entry<? extends String, ? extends VALUE> entry : 
map.entrySet()) {
+      builder.put(entry.getKey().toLowerCase(), entry.getValue());
+    }
+    return new CaseInsensitiveMap<>(builder.build());
+  }
+
+  private final Map<String, VALUE> underlyingMap;
+
+  /**
+   * Use the static factory methods to create instances of this class (e.g. 
{@link #newConcurrentMap}).
+   *
+   * @param underlyingMap the underlying map
+   */
+  private CaseInsensitiveMap(final Map<String, VALUE> underlyingMap) {
+    this.underlyingMap = underlyingMap;
+  }
+
+  @Override
+  public int size() {
+    return underlyingMap.size();
+  }
+
+  @Override
+  public boolean isEmpty() {
+    return underlyingMap.isEmpty();
+  }
+
+  @Override
+  public boolean containsKey(final Object key) {
+    return key instanceof String && underlyingMap.containsKey(((String) 
key).toLowerCase());
+  }
+
+  @Override
+  public boolean containsValue(final Object value) {
+    return underlyingMap.containsValue(value);
+  }
+
+  @Override
+  public VALUE get(final Object key) {
+    return key instanceof String ? underlyingMap.get(((String) 
key).toLowerCase()) : null;
+  }
+
+  @Override
+  public VALUE put(final String key, final VALUE value) {
+    return underlyingMap.put(key.toLowerCase(), value);
+  }
+
+  @Override
+  public VALUE remove(final Object key) {
+    return key instanceof String ? underlyingMap.remove(((String) 
key).toLowerCase()) : null;
+  }
+
+  @Override
+  public void putAll(final Map<? extends String, ? extends VALUE> map) {
+    for (final Entry<? extends String, ? extends VALUE> entry : 
map.entrySet()) {
+      underlyingMap.put(entry.getKey().toLowerCase(), entry.getValue());
+    }
+  }
+
+  @Override
+  public void clear() {
+    underlyingMap.clear();
+  }
+
+  @Override
+  public Set<String> keySet() {
+    return underlyingMap.keySet();
+  }
+
+  @Override
+  public Collection<VALUE> values() {
+    return underlyingMap.values();
+  }
+
+  @Override
+  public Set<Entry<String, VALUE>> entrySet() {
+    return underlyingMap.entrySet();
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/common/src/test/java/org/apache/drill/common/map/TestCaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git 
a/common/src/test/java/org/apache/drill/common/map/TestCaseInsensitiveMap.java 
b/common/src/test/java/org/apache/drill/common/map/TestCaseInsensitiveMap.java
new file mode 100644
index 0000000..8f31620
--- /dev/null
+++ 
b/common/src/test/java/org/apache/drill/common/map/TestCaseInsensitiveMap.java
@@ -0,0 +1,69 @@
+/**
+ * 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.common.map;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestCaseInsensitiveMap {
+
+  @Test
+  public void putAndGet() {
+    final CaseInsensitiveMap<Integer> map = 
CaseInsensitiveMap.newConcurrentMap();
+    assertTrue(map.isEmpty());
+    map.put("DRILL", 1);
+    map.put("bABy", 2);
+    map.put("drill!", 3);
+
+    assertTrue(!map.isEmpty());
+    assertEquals(3, map.size());
+    assertTrue(map.containsKey("drill"));
+    assertEquals(2, (long) map.get("BabY"));
+    assertNull(map.get(2));
+
+    assertEquals(3, (long) map.remove("DriLl!"));
+    assertEquals(2, map.size());
+
+    assertTrue(map.containsValue(1));
+  }
+
+  @Test
+  public void addAllFromAnother() {
+    final Map<String, Integer> another = new HashMap<>();
+    another.put("JuSt", 1);
+    another.put("DRILL", 2);
+    another.put("it", 3);
+
+    final Map<String, Integer> map = CaseInsensitiveMap.newConcurrentMap();
+    map.putAll(another);
+    assertEquals(3, map.size());
+    assertTrue(map.containsKey("just"));
+    assertEquals(2, (long) map.get("drill"));
+    assertEquals(3, (long) map.remove("IT"));
+
+    final Set<Map.Entry<String, Integer>> entrySet = map.entrySet();
+    assertEquals(2, entrySet.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
index 19c9f7f..2b1a230 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
@@ -18,10 +18,14 @@
 package org.apache.drill.exec.planner.sql.handlers;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 
+import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.tools.RelConversionException;
 import org.apache.calcite.tools.ValidationException;
 
+import org.apache.calcite.util.NlsString;
+import org.apache.drill.common.exceptions.ExpressionParsingException;
 import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.planner.sql.DirectPlan;
@@ -61,11 +65,50 @@ public class SetOptionHandler extends AbstractSqlHandler {
         default:
           throw new ValidationException("Invalid OPTION scope. Scope must be 
SESSION or SYSTEM.");
       }
-      context.getOptions().setOption(name, (SqlLiteral) value, type);
+      final OptionValue optionValue = createOptionValue(name, type, 
(SqlLiteral) value);
+      context.getOptions().setOption(optionValue);
     }else{
       throw new ValidationException("Sql options can only be literals.");
     }
 
     return DirectPlan.createDirectPlan(context, true, String.format("%s 
updated.", name));
   }
+
+  private static OptionValue createOptionValue(final String name, final 
OptionValue.OptionType type,
+                                               final SqlLiteral literal) {
+    final Object object = literal.getValue();
+    final SqlTypeName typeName = literal.getTypeName();
+    switch (typeName) {
+    case DECIMAL: {
+      final BigDecimal bigDecimal = (BigDecimal) object;
+      if (bigDecimal.scale() == 0) {
+        return OptionValue.createLong(type, name, bigDecimal.longValue());
+      } else {
+        return OptionValue.createDouble(type, name, bigDecimal.doubleValue());
+      }
+    }
+
+    case DOUBLE:
+    case FLOAT:
+      return OptionValue.createDouble(type, name, ((BigDecimal) 
object).doubleValue());
+
+    case SMALLINT:
+    case TINYINT:
+    case BIGINT:
+    case INTEGER:
+      return OptionValue.createLong(type, name, ((BigDecimal) 
object).longValue());
+
+    case VARBINARY:
+    case VARCHAR:
+    case CHAR:
+      return OptionValue.createString(type, name, ((NlsString) 
object).getValue());
+
+    case BOOLEAN:
+      return OptionValue.createBoolean(type, name, (Boolean) object);
+
+    default:
+      throw new ExpressionParsingException(String.format(
+        "Drill doesn't support set option expressions with literals of type 
%s.", typeName));
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/BaseOptionManager.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/BaseOptionManager.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/BaseOptionManager.java
index e15eddf..e973318 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/BaseOptionManager.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/BaseOptionManager.java
@@ -23,13 +23,13 @@ import 
org.apache.drill.exec.server.options.TypeValidators.LongValidator;
 import org.apache.drill.exec.server.options.TypeValidators.StringValidator;
 
 abstract class BaseOptionManager implements OptionManager {
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(BaseOptionManager.class);
+//  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(BaseOptionManager.class);
 
 
   private OptionValue getOptionSafe(OptionValidator validator){
     OptionValue value = getOption(validator.getOptionName());
     if(value == null){
-      throw new IllegalArgumentException(String.format("Unknown value for 
boolean option `%s`.", validator.getOptionName()));
+      throw new IllegalArgumentException(String.format("Unknown value for 
option `%s`.", validator.getOptionName()));
     }
     return value;
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/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 142fa0e..d96045c 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
@@ -19,77 +19,84 @@ package org.apache.drill.exec.server.options;
 
 import java.util.Iterator;
 
-import org.apache.drill.exec.server.options.OptionValue.OptionType;
-import org.apache.calcite.sql.SqlLiteral;
-
 import com.google.common.collect.Iterables;
 
+/**
+ * An {@link OptionManager} which allows for falling back onto another {@link 
OptionManager}. This way method calls can
+ * be delegated to the fallback manager in case the current manager does not 
handle the specified option. Also, all
+ * options do not need to be stored at every contextual level. For example, if 
an option isn't changed from its default
+ * within a session, then we can get the option from system options.
+ * <p/>
+ * {@link FragmentOptionManager} and {@link SessionOptionManager} use {@link 
SystemOptionManager} as the fall back
+ * manager. {@link QueryOptionManager} uses {@link SessionOptionManager} as 
the fall back manager.
+ */
 public abstract class FallbackOptionManager extends BaseOptionManager {
 //  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(FallbackOptionManager.class);
 
   protected final OptionManager fallback;
 
   public FallbackOptionManager(OptionManager fallback) {
+    /**
+     * TODO(DRILL-2097): Add a Preconditions.checkNotNull(fallback, "A 
fallback manager must be provided.") and remove
+     * the null check in {@link #getOption(String)}. This is not added 
currently only to avoid modifying the long list
+     * of test files.
+     */
     this.fallback = fallback;
   }
 
   @Override
   public Iterator<OptionValue> iterator() {
-    return Iterables.concat(fallback, optionIterable()).iterator();
+    return Iterables.concat(fallback, getLocalOptions()).iterator();
   }
 
   @Override
-  public OptionValue getOption(String name) {
-    final OptionValue opt = getLocalOption(name);
-    if(opt == null && fallback != null){
+  public OptionValue getOption(final String name) {
+    final OptionValue value = getLocalOption(name);
+    if (value == null && fallback != null) {
       return fallback.getOption(name);
-    }else{
-      return opt;
+    } else {
+      return value;
     }
   }
 
-  abstract Iterable<OptionValue> optionIterable();
+  /**
+   * Gets the option values managed by this manager as an iterable.
+   *
+   * @return iterable of option values
+   */
+  abstract Iterable<OptionValue> getLocalOptions();
+
+  /**
+   * Gets the option value from this manager without falling back.
+   *
+   * @param name the option name
+   * @return the option value, or null if the option does not exist locally
+   */
   abstract OptionValue getLocalOption(String name);
+
+  /**
+   * Sets the option value for this manager without falling back.
+   *
+   * @param value the option value
+   * @return true iff the value was successfully set
+   */
   abstract boolean setLocalOption(OptionValue value);
 
   @Override
   public void setOption(OptionValue value) {
-    fallback.getAdmin().validate(value);
-    setValidatedOption(value);
-  }
+    SystemOptionManager.getValidator(value.name).validate(value); // validate 
the option
 
-  @Override
-  public void setOption(String name, SqlLiteral literal, OptionType 
optionType) {
-    final OptionValue val = getAdmin().validate(name, literal, optionType);
-    setValidatedOption(val);
-  }
-
-  private void setValidatedOption(OptionValue value) {
+    // fallback if unable to set locally
     if (!setLocalOption(value)) {
       fallback.setOption(value);
     }
   }
 
   @Override
-  public OptionValue getDefault(final String name) {
-    return fallback.getDefault(name);
-  }
-
-  @Override
-  public OptionAdmin getAdmin() {
-    return fallback.getAdmin();
-  }
-
-  @Override
-  public OptionManager getSystemManager() {
-    return fallback.getSystemManager();
-  }
-
-  @Override
   public OptionList getOptionList() {
     final OptionList list = new OptionList();
-    for (OptionValue o : optionIterable()) {
-      list.add(o);
+    for (final OptionValue value : getLocalOptions()) {
+      list.add(value);
     }
     return list;
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FragmentOptionManager.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FragmentOptionManager.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FragmentOptionManager.java
index e4dbbf8..46e534a 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FragmentOptionManager.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FragmentOptionManager.java
@@ -17,31 +17,33 @@
  */
 package org.apache.drill.exec.server.options;
 
-import java.util.Map;
-
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
+import org.apache.drill.common.map.CaseInsensitiveMap;
+
+import java.util.Map;
 
+/**
+ * {@link OptionManager} that holds options within {@link 
org.apache.drill.exec.ops.FragmentContext}.
+ */
 public class FragmentOptionManager extends InMemoryOptionManager {
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(FragmentOptionManager.class);
+//  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(FragmentOptionManager.class);
 
   public FragmentOptionManager(OptionManager systemOptions, OptionList 
options) {
     super(systemOptions, getMapFromOptionList(options));
   }
 
-  private static Map<String, OptionValue> getMapFromOptionList(OptionList 
options){
-    Map<String, OptionValue> tmp = Maps.newHashMap();
-    for(OptionValue v : options){
-      tmp.put(v.name, v);
+  private static Map<String, OptionValue> getMapFromOptionList(final 
OptionList options) {
+    final Map<String, OptionValue> tmp = Maps.newHashMap();
+    for (final OptionValue value : options) {
+      tmp.put(value.name, value);
     }
-    return ImmutableMap.copyOf(tmp);
+    return CaseInsensitiveMap.newImmutableMap(tmp);
   }
 
   @Override
   boolean supportsOption(OptionValue value) {
-    throw new UnsupportedOperationException();
+    throw new UnsupportedOperationException("FragmentOptionManager does not 
support the given option value.");
   }
 
 
-
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/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 b033a03..dbff3e2 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
@@ -19,37 +19,47 @@ package org.apache.drill.exec.server.options;
 
 import java.util.Map;
 
+/**
+ * {@link OptionManager} that hold options in memory rather than in a 
persistent store. Option stored in
+ * {@link SessionOptionManager}, {@link QueryOptionManager}, and {@link 
FragmentOptionManager} are held in memory
+ * (see {@link #options}) whereas {@link SystemOptionManager} stores options 
in a persistent store.
+ */
 public abstract class InMemoryOptionManager extends FallbackOptionManager {
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(InMemoryOptionManager.class);
+//  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(InMemoryOptionManager.class);
 
-  final Map<String, OptionValue> options;
+  protected final Map<String, OptionValue> options;
 
-  InMemoryOptionManager(OptionManager fallback, Map<String, OptionValue> 
options) {
+  InMemoryOptionManager(final OptionManager fallback, final Map<String, 
OptionValue> options) {
     super(fallback);
     this.options = options;
   }
 
   @Override
-  OptionValue getLocalOption(String name) {
+  OptionValue getLocalOption(final String name) {
     return options.get(name);
   }
 
   @Override
-  boolean setLocalOption(OptionValue value) {
-    if(supportsOption(value)){
+  boolean setLocalOption(final OptionValue value) {
+    if (supportsOption(value)) {
       options.put(value.name, value);
       return true;
-    }else{
+    } else {
       return false;
     }
-
   }
 
   @Override
-  Iterable<OptionValue> optionIterable() {
+  Iterable<OptionValue> getLocalOptions() {
     return options.values();
   }
 
+  /**
+   * Check to see if implementations of this manager support the given option 
value (e.g. check for option type).
+   *
+   * @param value the option value
+   * @return true iff the option value is supported
+   */
   abstract boolean supportsOption(OptionValue value);
 
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
index 414713a..45535ae 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
@@ -17,26 +17,63 @@
  */
 package org.apache.drill.exec.server.options;
 
-import org.apache.calcite.sql.SqlLiteral;
-
+/**
+ * Manager for Drill options. Implementations must be case-insensitive to the 
name of an option.
+ */
 public interface OptionManager extends Iterable<OptionValue> {
-  public OptionValue getOption(String name);
-  public void setOption(OptionValue value) throws SetOptionException;
-  public void setOption(String name, SqlLiteral literal, 
OptionValue.OptionType type) throws SetOptionException;
-  public OptionAdmin getAdmin();
-  public OptionManager getSystemManager();
-  public OptionList getOptionList();
-  public OptionValue getDefault(final String name);
-
-  public boolean getOption(TypeValidators.BooleanValidator validator);
-  public double getOption(TypeValidators.DoubleValidator validator);
-  public long getOption(TypeValidators.LongValidator validator);
-  public String getOption(TypeValidators.StringValidator validator);
-
-  public interface OptionAdmin {
-    public void registerOptionType(OptionValidator validator);
-    public OptionValidator getValidator(String name);
-    public void validate(OptionValue v) throws SetOptionException;
-    public OptionValue validate(String name, SqlLiteral value, 
OptionValue.OptionType optionType) throws SetOptionException;
-  }
+
+  /**
+   * Sets an option value.
+   *
+   * @param value option value
+   * @throws IllegalArgumentException message to describe error with value
+   */
+  void setOption(OptionValue value);
+
+  /**
+   * Gets the option value for the given option name.
+   *
+   * @param name option name
+   * @return the option value, null if the option does not exist
+   */
+  OptionValue getOption(String name);
+
+  /**
+   * Gets the boolean value (from the option value) for the given boolean 
validator.
+   *
+   * @param validator the boolean validator
+   * @return the boolean value
+   */
+  boolean getOption(TypeValidators.BooleanValidator validator);
+
+  /**
+   * Gets the double value (from the option value) for the given double 
validator.
+   *
+   * @param validator the double validator
+   * @return the double value
+   */
+  double getOption(TypeValidators.DoubleValidator validator);
+
+  /**
+   * Gets the long value (from the option value) for the given long validator.
+   *
+   * @param validator the long validator
+   * @return the long value
+   */
+  long getOption(TypeValidators.LongValidator validator);
+
+  /**
+   * Gets the string value (from the option value) for the given string 
validator.
+   *
+   * @param validator the string validator
+   * @return the string value
+   */
+  String getOption(TypeValidators.StringValidator validator);
+
+  /**
+   * Gets the list of options managed this manager.
+   *
+   * @return the list of options
+   */
+  OptionList getOptionList();
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValidator.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValidator.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValidator.java
index 31a25fc..675c354 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValidator.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValidator.java
@@ -18,12 +18,9 @@
 package org.apache.drill.exec.server.options;
 
 import org.apache.drill.common.exceptions.ExpressionParsingException;
-import org.apache.calcite.sql.SqlLiteral;
 
 /**
  * Validates the values provided to Drill options.
- *
- * @param <E>
  */
 public abstract class OptionValidator {
   // Stored here as well as in the option static class to allow insertion of 
option optionName into
@@ -35,31 +32,23 @@ public abstract class OptionValidator {
   }
 
   /**
-   * This method determines if a given value is a valid setting for an option. 
For options that support some
-   * ambiguity in their settings, such as case-insensitivity for string 
options, this method returns a modified
-   * version of the passed value that is considered the standard format of the 
option that should be used for
-   * system-internal representation.
+   * Gets the name of the option for this validator.
    *
-   * @param value - the value to validate
-   * @return - the value requested, in its standard format to be used for 
representing the value within Drill
-   *            Example: all lower case values for strings, to avoid 
ambiguities in how values are stored
-   *            while allowing some flexibility for users
-   * @throws ExpressionParsingException - message to describe error with 
value, including range or list of expected values
+   * @return the option name
    */
-  public abstract OptionValue validate(SqlLiteral value, 
OptionValue.OptionType optionType) throws ExpressionParsingException;
-
   public String getOptionName() {
     return optionName;
   }
 
   /**
-   * This function returns true if and only if the validator is meant for a 
short-lived option.
+   * This function returns true if and only if this validator is meant for a 
short-lived option.
    *
    * NOTE: By default, options are not short-lived. So, if a derived class is 
meant for a short-lived option,
    * that class must do two things:
    * (1) override this method to return true, and
    * (2) return the number of queries for which the option is valid through 
{@link #getTtl}.
    * E.g. {@link 
org.apache.drill.exec.testing.ExecutionControls.ControlsOptionValidator}
+   *
    * @return if this validator is for a short-lived option
    */
   public boolean isShortLived() {
@@ -67,8 +56,9 @@ public abstract class OptionValidator {
   }
 
   /**
-   * If an option is short-lived, this returns the number of queries for which 
the option is valid.
+   * If an option is short-lived, this method returns the number of queries 
for which the option is valid.
    * Please read the note at {@link #isShortLived}
+   *
    * @return number of queries for which the option should be valid
    */
   public int getTtl() {
@@ -78,11 +68,18 @@ public abstract class OptionValidator {
     return 0;
   }
 
-  public String getDefaultString() {
-    return null;
-  }
-
+  /**
+   * Gets the default option value for this validator.
+   *
+   * @return default option value
+   */
   public abstract OptionValue getDefault();
 
-  public abstract void validate(OptionValue v) throws 
ExpressionParsingException;
+  /**
+   * Validates the option value.
+   *
+   * @param value the value to validate
+   * @throws ExpressionParsingException message to describe error with value
+   */
+  public abstract void validate(OptionValue value);
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/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 fa9223d..26cf688 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
@@ -17,18 +17,19 @@
  */
 package org.apache.drill.exec.server.options;
 
-import java.util.HashMap;
-
+import org.apache.drill.common.map.CaseInsensitiveMap;
 import org.apache.drill.exec.server.options.OptionValue.OptionType;
 
+/**
+ * {@link OptionManager} that holds options within {@link 
org.apache.drill.exec.ops.QueryContext}.
+ */
 public class QueryOptionManager extends InMemoryOptionManager {
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(SessionOptionManager.class);
+//  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(QueryOptionManager.class);
 
   public QueryOptionManager(OptionManager sessionOptions) {
-    super(sessionOptions, new HashMap<String, OptionValue>());
+    super(sessionOptions, CaseInsensitiveMap.<OptionValue>newHashMap());
   }
 
-
   @Override
   public OptionList getOptionList() {
     OptionList list = super.getOptionList();
@@ -36,11 +37,8 @@ public class QueryOptionManager extends 
InMemoryOptionManager {
     return list;
   }
 
-
   @Override
   boolean supportsOption(OptionValue value) {
     return value.type == OptionType.QUERY;
   }
-
-
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SessionOptionManager.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SessionOptionManager.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SessionOptionManager.java
index 340358f..d2bc82f 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SessionOptionManager.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SessionOptionManager.java
@@ -20,11 +20,15 @@ package org.apache.drill.exec.server.options;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.drill.common.map.CaseInsensitiveMap;
 import org.apache.drill.exec.rpc.user.UserSession;
 
 import java.util.Collection;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Map;
 
+/**
+ * {@link OptionManager} that holds options within {@link 
org.apache.drill.exec.rpc.user.UserSession} context.
+ */
 public class SessionOptionManager extends InMemoryOptionManager {
 //  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(SessionOptionManager.class);
 
@@ -33,40 +37,44 @@ public class SessionOptionManager extends 
InMemoryOptionManager {
   /**
    * Map of short lived options. Key: option name, Value: [ start, end )
    */
-  private final ConcurrentHashMap<String, ImmutablePair<Integer, Integer>> 
shortLivedOptions = new ConcurrentHashMap<>();
+  private final Map<String, ImmutablePair<Integer, Integer>> shortLivedOptions 
=
+    CaseInsensitiveMap.newConcurrentMap();
 
   public SessionOptionManager(final OptionManager systemOptions, final 
UserSession session) {
-    super(systemOptions, new ConcurrentHashMap<String, OptionValue>());
+    super(systemOptions, CaseInsensitiveMap.<OptionValue>newConcurrentMap());
     this.session = session;
   }
 
   @Override
   boolean setLocalOption(final OptionValue value) {
     final boolean set = super.setLocalOption(value);
+    if (!set) {
+      return false;
+    }
     final String name = value.name;
-    final OptionValidator validator = fallback.getAdmin().getValidator(name);
+    final OptionValidator validator = SystemOptionManager.getValidator(name);
     final boolean shortLived = validator.isShortLived();
-    if (set && shortLived) {
+    if (shortLived) {
       final int start = session.getQueryCount() + 1; // start from the next 
query
       final int ttl = validator.getTtl();
       final int end = start + ttl;
       shortLivedOptions.put(name, new ImmutablePair<>(start, end));
     }
-    return set;
+    return true;
   }
 
   @Override
   OptionValue getLocalOption(final String name) {
-    final OptionValue value = options.get(name);
+    final OptionValue value = super.getLocalOption(name);
     if (shortLivedOptions.containsKey(name)) {
-      if (withinRange(value)) {
+      if (withinRange(name)) {
         return value;
       }
       final int queryNumber = session.getQueryCount();
       final int start = shortLivedOptions.get(name).getLeft();
       // option is not in effect if queryNumber < start
       if (queryNumber < start) {
-        return fallback.getAdmin().getValidator(name).getDefault();
+        return SystemOptionManager.getValidator(name).getDefault();
       // reset if queryNumber <= end
       } else {
         options.remove(name);
@@ -77,9 +85,9 @@ public class SessionOptionManager extends 
InMemoryOptionManager {
     return value;
   }
 
-  private boolean withinRange(final OptionValue value) {
+  private boolean withinRange(final String name) {
     final int queryNumber = session.getQueryCount();
-    final ImmutablePair<Integer, Integer> pair = 
shortLivedOptions.get(value.name);
+    final ImmutablePair<Integer, Integer> pair = shortLivedOptions.get(name);
     final int start = pair.getLeft();
     final int end = pair.getRight();
     return start <= queryNumber && queryNumber < end;
@@ -89,12 +97,12 @@ public class SessionOptionManager extends 
InMemoryOptionManager {
     @Override
     public boolean apply(final OptionValue value) {
       final String name = value.name;
-      return !shortLivedOptions.containsKey(name) || withinRange(value);
+      return !shortLivedOptions.containsKey(name) || withinRange(name);
     }
   };
 
   @Override
-  Iterable<OptionValue> optionIterable() {
+  Iterable<OptionValue> getLocalOptions() {
     final Collection<OptionValue> liveOptions = 
Collections2.filter(options.values(), isLive);
     return liveOptions;
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
index 12db4d3..2df36dd 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
@@ -18,14 +18,14 @@
 package org.apache.drill.exec.server.options;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentMap;
 
-import com.google.common.collect.ImmutableList;
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.common.map.CaseInsensitiveMap;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.compile.ClassTransformer;
 import org.apache.drill.exec.compile.QueryClassLoader;
@@ -35,17 +35,18 @@ import org.apache.drill.exec.store.sys.PStore;
 import org.apache.drill.exec.store.sys.PStoreConfig;
 import org.apache.drill.exec.store.sys.PStoreProvider;
 import org.apache.drill.exec.util.AssertionUtil;
-import org.apache.calcite.sql.SqlLiteral;
-
-import com.google.common.collect.Maps;
 
+/**
+ * {@link OptionManager} that holds options within {@link 
org.apache.drill.exec.server.DrillbitContext}.
+ * Only one instance of this class exists per drillbit.
+ */
 public class SystemOptionManager extends BaseOptionManager {
   private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(SystemOptionManager.class);
 
-  private static final ImmutableList<OptionValidator> VALIDATORS;
+  private static final CaseInsensitiveMap<OptionValidator> VALIDATORS;
 
   static {
-    final ImmutableList.Builder<OptionValidator> builder = 
ImmutableList.<OptionValidator>builder().add(
+    final OptionValidator[] validators = new OptionValidator[]{
       PlannerSettings.CONSTANT_FOLDING,
       PlannerSettings.EXCHANGE,
       PlannerSettings.HASHAGG,
@@ -116,19 +117,27 @@ public class SystemOptionManager extends 
BaseOptionManager {
       ExecConstants.ENABLE_WINDOW_FUNCTIONS_VALIDATOR,
       ClassTransformer.SCALAR_REPLACEMENT_VALIDATOR,
       ExecConstants.ENABLE_NEW_TEXT_READER
-    );
+    };
+    final Map<String, OptionValidator> tmp = new HashMap<>();
+    for (final OptionValidator validator : validators) {
+      tmp.put(validator.getOptionName(), validator);
+    }
     if (AssertionUtil.isAssertionsEnabled()) {
-      builder.add(ExecConstants.DRILLBIT_CONTROLS_VALIDATOR);
+      tmp.put(ExecConstants.DRILLBIT_CONTROL_INJECTIONS, 
ExecConstants.DRILLBIT_CONTROLS_VALIDATOR);
     }
-    VALIDATORS = builder.build();
+    VALIDATORS = CaseInsensitiveMap.newImmutableMap(tmp);
   }
 
   private final PStoreConfig<OptionValue> config;
-  private PStore<OptionValue> options;
-  private SystemOptionAdmin admin;
-  private final ConcurrentMap<String, OptionValidator> knownOptions = 
Maps.newConcurrentMap();
+
   private final PStoreProvider provider;
 
+  /**
+   * Persistent store for options that have been changed from default.
+   * NOTE: CRUD operations must use lowercase keys.
+   */
+  private PStore<OptionValue> options;
+
   public SystemOptionManager(final DrillConfig config, final PStoreProvider 
provider) {
     this.provider = provider;
     this.config =  PStoreConfig.newJacksonBuilder(config.getMapper(), 
OptionValue.class)
@@ -136,135 +145,93 @@ public class SystemOptionManager extends 
BaseOptionManager {
         .build();
   }
 
+  /**
+   * Initializes this option manager.
+   *
+   * @return this option manager
+   * @throws IOException
+   */
   public SystemOptionManager init() throws IOException {
     options = provider.getStore(config);
-    admin = new SystemOptionAdmin();
+    // if necessary, deprecate and replace options from persistent store
+    for (final Entry<String, OptionValue> option : options) {
+      final String name = option.getKey();
+      final OptionValidator validator = VALIDATORS.get(name);
+      if (validator == null) {
+        // deprecated option, delete.
+        options.delete(name);
+        logger.warn("Deleting deprecated option `{}`", name);
+      } else {
+        final String canonicalName = validator.getOptionName().toLowerCase();
+        if (!name.equals(canonicalName)) {
+          // for backwards compatibility <= 1.1, rename to lower case.
+          logger.warn("Changing option name to lower case `{}`", name);
+          final OptionValue value = option.getValue();
+          options.delete(name);
+          options.put(canonicalName, value);
+        }
+      }
+    }
     return this;
   }
 
+  /**
+   * Gets the {@link OptionValidator} associated with the name.
+   *
+   * @param name name of the option
+   * @return the associated validator
+   * @throws IllegalArgumentException - if the validator is not found
+   */
+  public static OptionValidator getValidator(final String name) {
+    final OptionValidator validator = VALIDATORS.get(name);
+    if (validator == null) {
+      throw new IllegalArgumentException("Unknown option: " + name);
+    }
+    return validator;
+  }
+
   @Override
   public Iterator<OptionValue> iterator() {
-    final Map<String, OptionValue> buildList = Maps.newHashMap();
-    for(OptionValidator v : knownOptions.values()){
-      buildList.put(v.getOptionName(), v.getDefault());
+    final Map<String, OptionValue> buildList = CaseInsensitiveMap.newHashMap();
+    // populate the default options
+    for (final Map.Entry<String, OptionValidator> entry : 
VALIDATORS.entrySet()) {
+      buildList.put(entry.getKey(), entry.getValue().getDefault());
     }
-    for(Map.Entry<String, OptionValue> v : options){
-      final OptionValue value = v.getValue();
-      buildList.put(value.name, value);
+    // override if changed
+    for (final Map.Entry<String, OptionValue> entry : options) {
+      buildList.put(entry.getKey(), entry.getValue());
     }
     return buildList.values().iterator();
   }
 
   @Override
   public OptionValue getOption(final String name) {
-    // check local space
-    final OptionValue v = options.get(name);
-    if(v != null){
-      return v;
+    // check local space (persistent store)
+    final OptionValue value = options.get(name.toLowerCase());
+    if (value != null) {
+      return value;
     }
 
     // otherwise, return default.
-    OptionValidator validator = knownOptions.get(name);
-    if(validator == null) {
-      return null;
-    } else {
-      return validator.getDefault();
-    }
-  }
-
-  @Override
-  public OptionValue getDefault(final String name) {
-    final OptionValidator validator = knownOptions.get(name);
-    if(validator == null) {
-      return null;
-    } else {
-      return validator.getDefault();
-    }
+    final OptionValidator validator = getValidator(name);
+    return validator.getDefault();
   }
 
   @Override
   public void setOption(final OptionValue value) {
     assert value.type == OptionType.SYSTEM;
-    admin.validate(value);
-    setOptionInternal(value);
-  }
+    final String name = value.name.toLowerCase();
+    final OptionValidator validator = getValidator(name);
+    validator.validate(value); // validate the option
 
-  private void setOptionInternal(final OptionValue value) {
-    if (!value.equals(knownOptions.get(value.name))) {
-      options.put(value.name, value);
+    if (options.get(name) == null && value.equals(validator.getDefault())) {
+      return; // if the option is not overridden, ignore setting option to 
default
     }
-  }
-
-
-  @Override
-  public void setOption(final String name, final SqlLiteral literal, final 
OptionType type) {
-    assert type == OptionValue.OptionType.SYSTEM || type == 
OptionValue.OptionType.SESSION;
-    final OptionValue v = admin.validate(name, literal, type);
-    setOptionInternal(v);
+    options.put(name, value);
   }
 
   @Override
   public OptionList getOptionList() {
     return (OptionList) IteratorUtils.toList(iterator());
   }
-
-  @Override
-  public OptionManager getSystemManager() {
-    return this;
-  }
-
-  @Override
-  public OptionAdmin getAdmin() {
-    return admin;
-  }
-
-  private class SystemOptionAdmin implements OptionAdmin {
-    public SystemOptionAdmin() {
-      for(OptionValidator v : VALIDATORS) {
-        knownOptions.put(v.getOptionName(), v);
-      }
-
-      for(Entry<String, OptionValue> v : options) {
-        final OptionValue value = v.getValue();
-        final OptionValidator defaultValidator = knownOptions.get(v.getKey());
-        if (defaultValidator == null) {
-          // deprecated option, delete.
-          options.delete(value.name);
-          logger.warn("Deleting deprecated option `{}`.", value.name);
-        }
-      }
-    }
-
-    @Override
-    public void registerOptionType(final OptionValidator validator) {
-      if (null != knownOptions.putIfAbsent(validator.getOptionName(), 
validator)) {
-        throw new IllegalArgumentException("Only one option is allowed to be 
registered with name: "
-            + validator.getOptionName());
-      }
-    }
-
-    @Override
-    public OptionValidator getValidator(final String name) {
-      return knownOptions.get(name);
-    }
-
-    @Override
-    public void validate(final OptionValue v) throws SetOptionException {
-      final OptionValidator validator = knownOptions.get(v.name);
-      if (validator == null) {
-        throw new SetOptionException("Unknown option " + v.name);
-      }
-      validator.validate(v);
-    }
-
-    @Override
-    public OptionValue validate(final String name, final SqlLiteral value, 
final OptionType optionType)
-        throws SetOptionException {
-      final OptionValidator validator = knownOptions.get(name);
-      if (validator == null) {
-        throw new SetOptionException("Unknown option: " + name);
-      }
-      return validator.validate(value, optionType);
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
index b8597b7..829958a 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
@@ -18,7 +18,6 @@
 package org.apache.drill.exec.server.options;
 
 import java.io.IOException;
-import java.math.BigDecimal;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -27,10 +26,6 @@ import 
org.apache.drill.common.exceptions.ExpressionParsingException;
 import org.apache.drill.exec.server.options.OptionValue.Kind;
 import org.apache.drill.exec.server.options.OptionValue.OptionType;
 
-import org.apache.calcite.sql.type.SqlTypeName;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.util.NlsString;
-
 public class TypeValidators {
 //  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(TypeValidators.class);
 
@@ -203,14 +198,6 @@ public class TypeValidators {
     }
 
     @Override
-    public OptionValue validate(final SqlLiteral value, final OptionType 
optionType)
-        throws ExpressionParsingException {
-      final OptionValue op = getPartialValue(getOptionName(), optionType, 
value);
-      validate(op);
-      return op;
-    }
-
-    @Override
     public void validate(final OptionValue v) throws 
ExpressionParsingException {
       if (v.kind != kind) {
         throw new ExpressionParsingException(String.format(
@@ -219,41 +206,4 @@ public class TypeValidators {
       }
     }
   }
-
-  private static OptionValue getPartialValue(final String name, final 
OptionType type, final SqlLiteral literal) {
-    final Object object = literal.getValue();
-    final SqlTypeName typeName = literal.getTypeName();
-    switch (typeName) {
-    case DECIMAL: {
-      final BigDecimal bigDecimal = (BigDecimal) object;
-      if (bigDecimal.scale() == 0) {
-        return OptionValue.createLong(type, name, bigDecimal.longValue());
-      } else {
-        return OptionValue.createDouble(type, name, bigDecimal.doubleValue());
-      }
-    }
-
-    case DOUBLE:
-    case FLOAT:
-      return OptionValue.createDouble(type, name, ((BigDecimal) 
object).doubleValue());
-
-    case SMALLINT:
-    case TINYINT:
-    case BIGINT:
-    case INTEGER:
-      return OptionValue.createLong(type, name, ((BigDecimal) 
object).longValue());
-
-    case VARBINARY:
-    case VARCHAR:
-    case CHAR:
-      return OptionValue.createString(type, name, ((NlsString) 
object).getValue());
-
-    case BOOLEAN:
-      return OptionValue.createBoolean(type, name, (Boolean) object);
-
-    default:
-      throw new ExpressionParsingException(String.format(
-          "Drill doesn't support set option expressions with literals of type 
%s.", typeName));
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/OptionIterator.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/OptionIterator.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/OptionIterator.java
index 93109b7..85a1c3c 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/OptionIterator.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/OptionIterator.java
@@ -30,9 +30,10 @@ import 
org.apache.drill.exec.server.options.OptionValue.OptionType;
 
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
+import org.apache.drill.exec.server.options.SystemOptionManager;
 
 public class OptionIterator implements Iterator<Object> {
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(OptionIterator.class);
+//  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(OptionIterator.class);
 
   enum Mode {
     BOOT, SYS_SESS, BOTH
@@ -74,7 +75,7 @@ public class OptionIterator implements Iterator<Object> {
     if (value.type == OptionType.BOOT) {
       status = Status.BOOT;
     } else {
-      final OptionValue def = 
fragmentOptions.getSystemManager().getDefault(value.name);
+      final OptionValue def = 
SystemOptionManager.getValidator(value.name).getDefault();
       if (value.equalsIgnoreType(def)) {
         status = Status.DEFAULT;
         } else {

http://git-wip-us.apache.org/repos/asf/drill/blob/cc7bc953/exec/java-exec/src/test/java/org/apache/drill/exec/testing/ControlsInjectionUtil.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/testing/ControlsInjectionUtil.java
 
b/exec/java-exec/src/test/java/org/apache/drill/exec/testing/ControlsInjectionUtil.java
index 81f2015..d2aca37 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/testing/ControlsInjectionUtil.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/testing/ControlsInjectionUtil.java
@@ -29,6 +29,7 @@ import org.apache.drill.exec.server.options.OptionValue;
 
 import java.util.List;
 
+import static org.apache.drill.exec.ExecConstants.DRILLBIT_CONTROLS_VALIDATOR;
 import static org.apache.drill.exec.ExecConstants.DRILLBIT_CONTROL_INJECTIONS;
 import static org.junit.Assert.fail;
 
@@ -74,7 +75,7 @@ public class ControlsInjectionUtil {
 
     final OptionManager options = session.getOptions();
     try {
-      options.getAdmin().validate(opValue);
+      DRILLBIT_CONTROLS_VALIDATOR.validate(opValue);
       options.setOption(opValue);
     } catch (final Exception e) {
       fail("Could not set controls options: " + e.getMessage());

Reply via email to