You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2014/07/04 02:01:38 UTC

[8/8] git commit: Clean up.

Clean up.

Make StdFrameworkConfig a private inner class.


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

Branch: refs/heads/master
Commit: f12be81412495e325c3b214a70482d86d4766d8d
Parents: 55d67e2
Author: Julian Hyde <jh...@apache.org>
Authored: Thu Jul 3 16:41:04 2014 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Jul 3 16:43:10 2014 -0700

----------------------------------------------------------------------
 .../net/hydromatic/optiq/impl/ViewTable.java    |   4 +-
 .../optiq/prepare/OptiqPrepareImpl.java         |  31 +++--
 .../hydromatic/optiq/prepare/PlannerImpl.java   |   9 +-
 .../hydromatic/optiq/tools/FrameworkConfig.java |  70 +++++------
 .../net/hydromatic/optiq/tools/Frameworks.java  | 116 +++++++++++++++----
 .../net/hydromatic/optiq/tools/Programs.java    |   5 +
 .../optiq/tools/StdFrameworkConfig.java         | 108 -----------------
 .../org/eigenbase/relopt/RelOptPlanner.java     |   1 +
 .../java/org/eigenbase/relopt/RelOptUtil.java   |   1 -
 .../main/java/org/eigenbase/sql/SqlExplain.java |   2 +-
 .../eigenbase/sql/SqlUnresolvedFunction.java    |   5 +-
 .../sql/type/SqlTypeExplicitPrecedenceList.java |   3 +-
 .../eigenbase/util/ImmutableNullableList.java   |   3 +-
 13 files changed, 155 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/impl/ViewTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/impl/ViewTable.java b/core/src/main/java/net/hydromatic/optiq/impl/ViewTable.java
index 64d0190..f6cd347 100644
--- a/core/src/main/java/net/hydromatic/optiq/impl/ViewTable.java
+++ b/core/src/main/java/net/hydromatic/optiq/impl/ViewTable.java
@@ -135,12 +135,12 @@ public class ViewTable
     }
   }
 
-  /** Get the view's SQL definition. */
+  /** Returns the view's SQL definition. */
   public String getViewSql() {
     return viewSql;
   }
 
-  /** Get the schemapath of the view */
+  /** Returns the the schema path of the view. */
   public List<String> getSchemaPath() {
     return schemaPath;
   }

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/prepare/OptiqPrepareImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/prepare/OptiqPrepareImpl.java b/core/src/main/java/net/hydromatic/optiq/prepare/OptiqPrepareImpl.java
index 4483c57..41f6e58 100644
--- a/core/src/main/java/net/hydromatic/optiq/prepare/OptiqPrepareImpl.java
+++ b/core/src/main/java/net/hydromatic/optiq/prepare/OptiqPrepareImpl.java
@@ -22,7 +22,6 @@ import net.hydromatic.avatica.ColumnMetaData;
 import net.hydromatic.avatica.Helper;
 
 import net.hydromatic.linq4j.*;
-
 import net.hydromatic.linq4j.expressions.*;
 import net.hydromatic.linq4j.function.Function1;
 
@@ -196,10 +195,10 @@ public class OptiqPrepareImpl implements OptiqPrepare {
 
   /** Creates a query planner and initializes it with a default set of
    * rules. */
-  protected RelOptPlanner createPlanner(OptiqPrepare.Context prepareContext, //
-      org.eigenbase.relopt.Context externalContext, //
+  protected RelOptPlanner createPlanner(OptiqPrepare.Context prepareContext,
+      org.eigenbase.relopt.Context externalContext,
       RelOptCostFactory costFactory) {
-    final VolcanoPlanner planner = //
+    final VolcanoPlanner planner =
         new VolcanoPlanner(costFactory, externalContext);
     planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
     if (ENABLE_COLLATION_TRAIT) {
@@ -555,24 +554,24 @@ public class OptiqPrepareImpl implements OptiqPrepare {
   /** Executes a prepare action. */
   public <R> R perform(OptiqServerStatement statement,
       Frameworks.PrepareAction<R> action) {
-    final OptiqPrepare.Context prepareContext = statement
-        .createPrepareContext();
+    final OptiqPrepare.Context prepareContext =
+        statement.createPrepareContext();
     final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
-    OptiqCatalogReader catalogReader = new OptiqCatalogReader(
-        prepareContext.getRootSchema(),
-        prepareContext.config().caseSensitive(),
-        prepareContext.getDefaultSchemaPath(),
-        typeFactory);
+    OptiqCatalogReader catalogReader =
+        new OptiqCatalogReader(prepareContext.getRootSchema(),
+            prepareContext.config().caseSensitive(),
+            prepareContext.getDefaultSchemaPath(),
+            typeFactory);
     final RexBuilder rexBuilder = new RexBuilder(typeFactory);
-    final RelOptPlanner planner = createPlanner(prepareContext, //
-        action.getConfig().getContext(), //
-        action.getConfig().getCostFactory());
+    final RelOptPlanner planner =
+        createPlanner(prepareContext,
+            action.getConfig().getContext(),
+            action.getConfig().getCostFactory());
     final RelOptQuery query = new RelOptQuery(planner);
     final RelOptCluster cluster =
         query.createCluster(rexBuilder.getTypeFactory(), rexBuilder);
     return action.apply(cluster, catalogReader,
-        prepareContext.getRootSchema().plus(),
-        statement);
+        prepareContext.getRootSchema().plus(), statement);
   }
 
   static class OptiqPreparingStmt extends Prepare

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/prepare/PlannerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/prepare/PlannerImpl.java b/core/src/main/java/net/hydromatic/optiq/prepare/PlannerImpl.java
index 6bc8704..c87102d 100644
--- a/core/src/main/java/net/hydromatic/optiq/prepare/PlannerImpl.java
+++ b/core/src/main/java/net/hydromatic/optiq/prepare/PlannerImpl.java
@@ -76,8 +76,6 @@ public class PlannerImpl implements Planner {
   private SqlRexConvertletTable convertletTable;
   private RelNode rel;
 
-
-
   /** Creates a planner. Not a public API; call
    * {@link net.hydromatic.optiq.tools.Frameworks#getPlanner} instead. */
   public PlannerImpl(FrameworkConfig config) {
@@ -197,7 +195,7 @@ public class PlannerImpl implements Planner {
   }
 
   /** Implements {@link org.eigenbase.relopt.RelOptTable.ViewExpander}
-   * interface for {@link net.hydromatic.optiq.tools.Planner} */
+   * interface for {@link net.hydromatic.optiq.tools.Planner}. */
   public class ViewExpanderImpl implements ViewExpander {
     public RelNode expandView(RelDataType rowType, String queryString,
         List<String> schemaPath) {
@@ -221,10 +219,7 @@ public class PlannerImpl implements Planner {
           createRexBuilder(), convertletTable);
       sqlToRelConverter.setTrimUnusedFields(false);
 
-      RelNode relNode = sqlToRelConverter.convertQuery(
-          validatedSqlNode, true, false);
-
-      return relNode;
+      return sqlToRelConverter.convertQuery(validatedSqlNode, true, false);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/tools/FrameworkConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/tools/FrameworkConfig.java b/core/src/main/java/net/hydromatic/optiq/tools/FrameworkConfig.java
index f32cf35..5930fdd 100644
--- a/core/src/main/java/net/hydromatic/optiq/tools/FrameworkConfig.java
+++ b/core/src/main/java/net/hydromatic/optiq/tools/FrameworkConfig.java
@@ -34,88 +34,80 @@ import com.google.common.collect.ImmutableList;
  * using the Frameworks tools.
  */
 public interface FrameworkConfig {
-
   /**
-   * The type of lexing the SqlParser should do.  Controls case rules
+   * The type of lexical analysis the SqlParser should do.  Controls case rules
    * and quoted identifier syntax.
    */
   Lex getLex();
 
-
   /**
-   * Provides the Parser factory that creates the SqlParser used in parsing
+   * Provides the parser factory that creates the SqlParser used in parsing
    * queries.
    */
   SqlParserImplFactory getParserFactory();
 
   /**
    * Returns the default schema that should be checked before looking at the
-   * root schema.  Return null to only consult the root schema.
+   * root schema.  Returns null to only consult the root schema.
    */
   SchemaPlus getDefaultSchema();
 
-
   /**
-   * List of of one or more programs used during the course of
-   *     query evaluation. The common use case is when there is a single program
-   *     created using {@link Programs#of(RuleSet)}
-   *     and {@link net.hydromatic.optiq.tools.Planner#transform}
-   *     will only be called once. However, consumers may also create programs
-   *     not based on rule sets, register multiple programs,
-   *     and do multiple repetitions
-   *     of {@link Planner#transform} planning cycles using different indices.
-   *     The order of programs provided here determines the zero-based indices
-   *     of programs elsewhere in this class.
+   * Returns a list of one or more programs used during the course of query
+   * evaluation.
+   *
+   * <p>The common use case is when there is a single program
+   * created using {@link Programs#of(RuleSet)}
+   * and {@link net.hydromatic.optiq.tools.Planner#transform}
+   * will only be called once.
+   *
+   * <p>However, consumers may also create programs
+   * not based on rule sets, register multiple programs,
+   * and do multiple repetitions
+   * of {@link Planner#transform} planning cycles using different indices.
+   *
+   * <p>The order of programs provided here determines the zero-based indices
+   * of programs elsewhere in this class.
    */
   ImmutableList<Program> getPrograms();
 
-
   /**
-   * Return the instance of SqlOperatorTable that should be used to
-   * resolve Optiq operators.
+   * Returns operator table that should be used to
+   * resolve functions and operators during query validation.
    */
   SqlOperatorTable getOperatorTable();
 
-
-
   /**
-   * Return the cost factory that should be used when creating the planner.
+   * Returns the cost factory that should be used when creating the planner.
    * If null, use the default cost factory for that planner.
    */
   RelOptCostFactory getCostFactory();
 
-
-/**
-   * <p>If {@code traitDefs} is non-null, the planner first de-registers any
+  /**
+   * Returns a list of trait definitions.
+   *
+   * <p>If the list is not null, the planner first de-registers any
    * existing {@link RelTraitDef}s, then registers the {@code RelTraitDef}s in
    * this list.</p>
    *
-   * <p>The order of {@code RelTraitDef}s in {@code traitDefs} matters if the
+   * <p>The order of {@code RelTraitDef}s in the list matters if the
    * planner is VolcanoPlanner. The planner calls {@link RelTraitDef#convert} in
    * the order of this list. The most important trait comes first in the list,
    * followed by the second most important one, etc.</p>
-   *
-   * @param lex The type of lexing the SqlParser should do.  Controls case rules
-   *     and quoted identifier syntax.
-   * @param parserFactory
-   * @param operatorTable The instance of SqlOperatorTable that be should to
-   *     resolve Optiq operators.
-   * @param ruleSets
-   *  @param  traitDefs The list of RelTraitDef that would be registered with
-   *     planner, or null.
- * @return
- */
+   */
   ImmutableList<RelTraitDef> getTraitDefs();
 
   /**
-   * Return the convertlet table that should be used when converting from Sql
+   * Returns the convertlet table that should be used when converting from SQL
    * to row expressions
    */
   SqlRexConvertletTable getConvertletTable();
 
   /**
    * Returns the PlannerContext that should be made available during planning by
-   * calling {@link org.eigenbase.relopt.RelOptPlanner#getPlannerContext}
+   * calling {@link org.eigenbase.relopt.RelOptPlanner#getContext()}.
    */
   Context getContext();
 }
+
+// End FrameworkConfig.java

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/tools/Frameworks.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/tools/Frameworks.java b/core/src/main/java/net/hydromatic/optiq/tools/Frameworks.java
index 6472c43..48d9c8d 100644
--- a/core/src/main/java/net/hydromatic/optiq/tools/Frameworks.java
+++ b/core/src/main/java/net/hydromatic/optiq/tools/Frameworks.java
@@ -52,6 +52,12 @@ public class Frameworks {
   private Frameworks() {
   }
 
+  /**
+   * Creates a planner.
+   *
+   * @param config Planner configuration
+   * @return Planner
+   */
   public static Planner getPlanner(FrameworkConfig config) {
     return new PlannerImpl(config);
   }
@@ -135,7 +141,6 @@ public class Frameworks {
           connection.unwrap(OptiqConnection.class);
       final OptiqServerStatement statement =
           optiqConnection.createStatement().unwrap(OptiqServerStatement.class);
-      //noinspection deprecation
       return new OptiqPrepareImpl().perform(statement, action);
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -157,7 +162,7 @@ public class Frameworks {
   }
 
   /**
-   * A builder class to help you build a StdFrameworkConfig using defaults
+   * A builder to help you build a {@link FrameworkConfig} using defaults
    * where values aren't required.
    */
   public static class ConfigBuilder {
@@ -176,25 +181,22 @@ public class Frameworks {
 
     public FrameworkConfig build() {
       return new StdFrameworkConfig(context, convertletTable, operatorTable,
-          programs, traitDefs, lex, defaultSchema, costFactory, //
-          parserFactory);
+          programs, traitDefs, lex, defaultSchema, costFactory, parserFactory);
     }
 
     public ConfigBuilder context(Context c) {
-      Preconditions.checkNotNull(c);
-      this.context = c;
+      this.context = Preconditions.checkNotNull(c);
       return this;
-    };
+    }
 
-    public ConfigBuilder convertletTable(SqlRexConvertletTable table) {
-      Preconditions.checkNotNull(table);
-      this.convertletTable = table;
+    public ConfigBuilder convertletTable(
+        SqlRexConvertletTable convertletTable) {
+      this.convertletTable = Preconditions.checkNotNull(convertletTable);
       return this;
     }
 
-    public ConfigBuilder operatorTable(SqlOperatorTable table) {
-      Preconditions.checkNotNull(table);
-      this.operatorTable = table;
+    public ConfigBuilder operatorTable(SqlOperatorTable operatorTable) {
+      this.operatorTable = Preconditions.checkNotNull(operatorTable);
       return this;
     }
 
@@ -213,8 +215,7 @@ public class Frameworks {
     }
 
     public ConfigBuilder lex(Lex lex) {
-      Preconditions.checkNotNull(lex);
-      this.lex = lex;
+      this.lex = Preconditions.checkNotNull(lex);
       return this;
     }
 
@@ -228,11 +229,12 @@ public class Frameworks {
       return this;
     }
 
+    public ConfigBuilder ruleSets(RuleSet... ruleSets) {
+      return programs(Programs.listOf(ruleSets));
+    }
+
     public ConfigBuilder ruleSets(List<RuleSet> ruleSets) {
-      Preconditions.checkNotNull(ruleSets);
-      this.programs = ImmutableList.copyOf(Programs.listOf(ruleSets.toArray(
-          new RuleSet[ruleSets.size()])));
-      return this;
+      return programs(Programs.listOf(Preconditions.checkNotNull(ruleSets)));
     }
 
     public ConfigBuilder programs(List<Program> programs) {
@@ -245,15 +247,81 @@ public class Frameworks {
       return this;
     }
 
-    public ConfigBuilder ruleSets(RuleSet... ruleSets) {
-      this.programs = ImmutableList.copyOf(Programs.listOf(ruleSets));
+    public ConfigBuilder parserFactory(SqlParserImplFactory parserFactory) {
+      this.parserFactory = Preconditions.checkNotNull(parserFactory);
       return this;
     }
+  }
 
-    public ConfigBuilder parserFactory(SqlParserImplFactory parserFactory) {
-      Preconditions.checkNotNull(parserFactory);
+  /**
+   * An implementation of {@link FrameworkConfig} that uses standard Optiq
+   * classes to provide basic planner functionality.
+   */
+  static class StdFrameworkConfig implements FrameworkConfig {
+    private final Context context;
+    private final SqlRexConvertletTable convertletTable;
+    private final SqlOperatorTable operatorTable;
+    private final ImmutableList<Program> programs;
+    private final ImmutableList<RelTraitDef> traitDefs;
+    private final Lex lex;
+    private final SchemaPlus defaultSchema;
+    private final RelOptCostFactory costFactory;
+    private final SqlParserImplFactory parserFactory;
+
+    public StdFrameworkConfig(Context context,
+        SqlRexConvertletTable convertletTable,
+        SqlOperatorTable operatorTable,
+        ImmutableList<Program> programs,
+        ImmutableList<RelTraitDef> traitDefs,
+        Lex lex,
+        SchemaPlus defaultSchema,
+        RelOptCostFactory costFactory,
+        SqlParserImplFactory parserFactory) {
+      this.context = context;
+      this.convertletTable = convertletTable;
+      this.operatorTable = operatorTable;
+      this.programs = programs;
+      this.traitDefs = traitDefs;
+      this.lex = lex;
+      this.defaultSchema = defaultSchema;
+      this.costFactory = costFactory;
       this.parserFactory = parserFactory;
-      return this;
+    }
+
+    public Lex getLex() {
+      return lex;
+    }
+
+    public SqlParserImplFactory getParserFactory() {
+      return parserFactory;
+    }
+
+    public SchemaPlus getDefaultSchema() {
+      return defaultSchema;
+    }
+
+    public ImmutableList<Program> getPrograms() {
+      return programs;
+    }
+
+    public RelOptCostFactory getCostFactory() {
+      return costFactory;
+    }
+
+    public ImmutableList<RelTraitDef> getTraitDefs() {
+      return traitDefs;
+    }
+
+    public SqlRexConvertletTable getConvertletTable() {
+      return convertletTable;
+    }
+
+    public Context getContext() {
+      return context;
+    }
+
+    public SqlOperatorTable getOperatorTable() {
+      return operatorTable;
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/tools/Programs.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/tools/Programs.java b/core/src/main/java/net/hydromatic/optiq/tools/Programs.java
index 6c14857..788971f 100644
--- a/core/src/main/java/net/hydromatic/optiq/tools/Programs.java
+++ b/core/src/main/java/net/hydromatic/optiq/tools/Programs.java
@@ -54,6 +54,11 @@ public class Programs {
     return Lists.transform(Arrays.asList(ruleSets), RULE_SET_TO_PROGRAM);
   }
 
+  /** Creates a list of programs based on a list of rule sets. */
+  public static List<Program> listOf(List<RuleSet> ruleSets) {
+    return Lists.transform(ruleSets, RULE_SET_TO_PROGRAM);
+  }
+
   /** Creates a program from a list of rules. */
   public static Program ofRules(RelOptRule... rules) {
     return of(RuleSets.ofList(rules));

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/net/hydromatic/optiq/tools/StdFrameworkConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/net/hydromatic/optiq/tools/StdFrameworkConfig.java b/core/src/main/java/net/hydromatic/optiq/tools/StdFrameworkConfig.java
deleted file mode 100644
index c850228..0000000
--- a/core/src/main/java/net/hydromatic/optiq/tools/StdFrameworkConfig.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-// Licensed to Julian Hyde under one or more contributor license
-// agreements. See the NOTICE file distributed with this work for
-// additional information regarding copyright ownership.
-//
-// Julian Hyde 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 net.hydromatic.optiq.tools;
-
-
-import net.hydromatic.optiq.SchemaPlus;
-import net.hydromatic.optiq.config.Lex;
-
-import org.eigenbase.relopt.Context;
-import org.eigenbase.relopt.RelOptCostFactory;
-import org.eigenbase.relopt.RelTraitDef;
-import org.eigenbase.sql.SqlOperatorTable;
-import org.eigenbase.sql.parser.SqlParserImplFactory;
-import org.eigenbase.sql2rel.SqlRexConvertletTable;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * An implementation of {@link FrameworkConfig} that uses standard Optiq
- * classes to provide basic planner functionality.
- */
-class StdFrameworkConfig implements FrameworkConfig {
-
-  private final Context context;
-  private final SqlRexConvertletTable convertletTable;
-  private final SqlOperatorTable operatorTable;
-  private final ImmutableList<Program> programs;
-  private final ImmutableList<RelTraitDef> traitDefs;
-  private final Lex lex;
-  private final SchemaPlus defaultSchema;
-  private final RelOptCostFactory costFactory;
-  private final SqlParserImplFactory parserFactory;
-
-
-  public StdFrameworkConfig(Context context, //
-      SqlRexConvertletTable convertletTable, //
-      SqlOperatorTable operatorTable, //
-      ImmutableList<Program> programs, //
-      ImmutableList<RelTraitDef> traitDefs,
-      Lex lex, //
-      SchemaPlus defaultSchema, //
-      RelOptCostFactory costFactory, //
-      SqlParserImplFactory parserFactory) {
-    super();
-    this.context = context;
-    this.convertletTable = convertletTable;
-    this.operatorTable = operatorTable;
-    this.programs = programs;
-    this.traitDefs = traitDefs;
-    this.lex = lex;
-    this.defaultSchema = defaultSchema;
-    this.costFactory = costFactory;
-    this.parserFactory = parserFactory;
-  }
-
-  public Lex getLex() {
-    return lex;
-  }
-
-  public SqlParserImplFactory getParserFactory() {
-    return parserFactory;
-  }
-
-  public SchemaPlus getDefaultSchema() {
-    return defaultSchema;
-  }
-
-  public ImmutableList<Program> getPrograms() {
-    return programs;
-  }
-
-  public RelOptCostFactory getCostFactory() {
-    return costFactory;
-  }
-
-  public ImmutableList<RelTraitDef> getTraitDefs() {
-    return traitDefs;
-  }
-
-  public SqlRexConvertletTable getConvertletTable() {
-    return convertletTable;
-  }
-
-  public Context getContext() {
-    return context;
-  }
-
-  public SqlOperatorTable getOperatorTable() {
-    return operatorTable;
-  }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/org/eigenbase/relopt/RelOptPlanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/relopt/RelOptPlanner.java b/core/src/main/java/org/eigenbase/relopt/RelOptPlanner.java
index 192d2aa..3c5b235 100644
--- a/core/src/main/java/org/eigenbase/relopt/RelOptPlanner.java
+++ b/core/src/main/java/org/eigenbase/relopt/RelOptPlanner.java
@@ -100,6 +100,7 @@ public interface RelOptPlanner {
 
   /**
    * Provides the Context created when this planner was constructed.
+   *
    * @return Either null or an externally defined context.
    */
   Context getContext();

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/org/eigenbase/relopt/RelOptUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/relopt/RelOptUtil.java b/core/src/main/java/org/eigenbase/relopt/RelOptUtil.java
index 24ee23f..941deb9 100644
--- a/core/src/main/java/org/eigenbase/relopt/RelOptUtil.java
+++ b/core/src/main/java/org/eigenbase/relopt/RelOptUtil.java
@@ -1458,7 +1458,6 @@ public abstract class RelOptUtil {
       final String desc2,
       RelDataType type2,
       boolean fail) {
-
     // if any one of the types is ANY return true
     if (type1.getSqlTypeName() == SqlTypeName.ANY
         || type2.getSqlTypeName() == SqlTypeName.ANY) {

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/org/eigenbase/sql/SqlExplain.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/SqlExplain.java b/core/src/main/java/org/eigenbase/sql/SqlExplain.java
index 871dddc..26860b7 100644
--- a/core/src/main/java/org/eigenbase/sql/SqlExplain.java
+++ b/core/src/main/java/org/eigenbase/sql/SqlExplain.java
@@ -32,11 +32,11 @@ public class SqlExplain extends SqlCall {
         @Override
         public SqlCall createCall(SqlLiteral functionQualifier,
             SqlParserPos pos, SqlNode... operands) {
-          //explicandum, detailLevel, depth, asXml
           return new SqlExplain(pos, operands[0], (SqlLiteral) operands[1],
               (SqlLiteral) operands[2], (SqlLiteral) operands[3], 0);
         }
       };
+
   //~ Enums ------------------------------------------------------------------
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/org/eigenbase/sql/SqlUnresolvedFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/SqlUnresolvedFunction.java b/core/src/main/java/org/eigenbase/sql/SqlUnresolvedFunction.java
index d40754a..1ab6e27 100644
--- a/core/src/main/java/org/eigenbase/sql/SqlUnresolvedFunction.java
+++ b/core/src/main/java/org/eigenbase/sql/SqlUnresolvedFunction.java
@@ -57,7 +57,9 @@ public class SqlUnresolvedFunction extends SqlFunction {
   }
 
   /**
-   * The operator class for this function isn't resolved to the
+   * {@inheritDoc}T
+   *
+   * <p>The operator class for this function isn't resolved to the
    * correct class. This happens in the case of user defined
    * functions. Return the return type to be 'ANY', so we don't
    * fail.
@@ -67,7 +69,6 @@ public class SqlUnresolvedFunction extends SqlFunction {
       SqlOperatorBinding opBinding) {
     return new BasicSqlType(SqlTypeName.ANY);
   }
-
 }
 
 // End SqlUnresolvedFunction.java

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/org/eigenbase/sql/type/SqlTypeExplicitPrecedenceList.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql/type/SqlTypeExplicitPrecedenceList.java b/core/src/main/java/org/eigenbase/sql/type/SqlTypeExplicitPrecedenceList.java
index 457050f..f3f14ca 100644
--- a/core/src/main/java/org/eigenbase/sql/type/SqlTypeExplicitPrecedenceList.java
+++ b/core/src/main/java/org/eigenbase/sql/type/SqlTypeExplicitPrecedenceList.java
@@ -97,8 +97,7 @@ public class SqlTypeExplicitPrecedenceList
   //~ Constructors -----------------------------------------------------------
 
   public SqlTypeExplicitPrecedenceList(List<SqlTypeName> typeNames) {
-    this.typeNames = new ArrayList();
-    this.typeNames.addAll(typeNames);
+    this.typeNames = ImmutableNullableList.copyOf(typeNames);
   }
 
   //~ Methods ----------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/f12be814/core/src/main/java/org/eigenbase/util/ImmutableNullableList.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/util/ImmutableNullableList.java b/core/src/main/java/org/eigenbase/util/ImmutableNullableList.java
index 3f104b1..39c8921 100644
--- a/core/src/main/java/org/eigenbase/util/ImmutableNullableList.java
+++ b/core/src/main/java/org/eigenbase/util/ImmutableNullableList.java
@@ -48,7 +48,8 @@ public class ImmutableNullableList<E> extends AbstractList<E> {
    */
   public static <E> List<E> copyOf(Collection<? extends E> elements) {
     if (elements instanceof ImmutableNullableList
-        || elements instanceof ImmutableList) {
+        || elements instanceof ImmutableList
+        || elements == SINGLETON_NULL) {
       //noinspection unchecked
       return (List<E>) elements;
     }