calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [21/58] [abbrv] [partial] incubator-calcite git commit: [CALCITE-306] Standardize code style for "import package.*; "
Date Fri, 14 Nov 2014 21:32:29 GMT
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/sql2rel/SqlRexConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlRexConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlRexConvertletTable.java
index 09a6a75..b1e0a51 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlRexConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlRexConvertletTable.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.sql2rel;
+package org.apache.calcite.sql2rel;
 
-import org.eigenbase.sql.*;
+import org.apache.calcite.sql.SqlCall;
 
 /**
  * Collection of {@link SqlRexConvertlet}s.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index c940b6c..ce1cb4a 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -14,47 +14,160 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.sql2rel;
-
-import java.lang.reflect.Type;
-import java.math.*;
-import java.util.*;
-import java.util.logging.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.metadata.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.reltype.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.*;
-import org.eigenbase.sql.fun.*;
-import org.eigenbase.sql.parser.*;
-import org.eigenbase.sql.type.*;
-import org.eigenbase.sql.util.*;
-import org.eigenbase.sql.validate.*;
-import org.eigenbase.trace.*;
-import org.eigenbase.util.*;
-import org.eigenbase.util.mapping.Mappings;
-import org.eigenbase.util14.*;
-
-import net.hydromatic.linq4j.Ord;
-
-import net.hydromatic.optiq.ModifiableTable;
-import net.hydromatic.optiq.TranslatableTable;
-import net.hydromatic.optiq.prepare.Prepare;
-import net.hydromatic.optiq.prepare.RelOptTableImpl;
-import net.hydromatic.optiq.util.BitSets;
+package org.apache.calcite.sql2rel;
+
+import org.apache.calcite.linq4j.Ord;
+import org.apache.calcite.plan.Convention;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.plan.RelOptQuery;
+import org.apache.calcite.plan.RelOptSamplingParameters;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.prepare.Prepare;
+import org.apache.calcite.prepare.RelOptTableImpl;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelCollationImpl;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.Collect;
+import org.apache.calcite.rel.core.Correlation;
+import org.apache.calcite.rel.core.Correlator;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinInfo;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.Sample;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.Uncollect;
+import org.apache.calcite.rel.logical.LogicalAggregate;
+import org.apache.calcite.rel.logical.LogicalIntersect;
+import org.apache.calcite.rel.logical.LogicalJoin;
+import org.apache.calcite.rel.logical.LogicalMinus;
+import org.apache.calcite.rel.logical.LogicalOneRow;
+import org.apache.calcite.rel.logical.LogicalProject;
+import org.apache.calcite.rel.logical.LogicalTableFunctionScan;
+import org.apache.calcite.rel.logical.LogicalTableModify;
+import org.apache.calcite.rel.logical.LogicalTableScan;
+import org.apache.calcite.rel.logical.LogicalUnion;
+import org.apache.calcite.rel.logical.LogicalValues;
+import org.apache.calcite.rel.metadata.RelColumnMapping;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexCallBinding;
+import org.apache.calcite.rex.RexCorrelVariable;
+import org.apache.calcite.rex.RexDynamicParam;
+import org.apache.calcite.rex.RexFieldAccess;
+import org.apache.calcite.rex.RexFieldCollation;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexRangeRef;
+import org.apache.calcite.rex.RexShuttle;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.rex.RexWindowBound;
+import org.apache.calcite.schema.ModifiableTable;
+import org.apache.calcite.schema.TranslatableTable;
+import org.apache.calcite.sql.JoinConditionType;
+import org.apache.calcite.sql.JoinType;
+import org.apache.calcite.sql.SqlAggFunction;
+import org.apache.calcite.sql.SqlBasicCall;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlDelete;
+import org.apache.calcite.sql.SqlDynamicParam;
+import org.apache.calcite.sql.SqlExplainLevel;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlInsert;
+import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.SqlJoin;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlMerge;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlOperatorTable;
+import org.apache.calcite.sql.SqlSampleSpec;
+import org.apache.calcite.sql.SqlSelect;
+import org.apache.calcite.sql.SqlSelectKeyword;
+import org.apache.calcite.sql.SqlSetOperator;
+import org.apache.calcite.sql.SqlUpdate;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.SqlWindow;
+import org.apache.calcite.sql.SqlWith;
+import org.apache.calcite.sql.SqlWithItem;
+import org.apache.calcite.sql.fun.SqlCountAggFunction;
+import org.apache.calcite.sql.fun.SqlInOperator;
+import org.apache.calcite.sql.fun.SqlRowOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.apache.calcite.sql.type.TableFunctionReturnTypeInference;
+import org.apache.calcite.sql.util.SqlBasicVisitor;
+import org.apache.calcite.sql.util.SqlVisitor;
+import org.apache.calcite.sql.validate.CollectNamespace;
+import org.apache.calcite.sql.validate.DelegatingScope;
+import org.apache.calcite.sql.validate.ListScope;
+import org.apache.calcite.sql.validate.ParameterScope;
+import org.apache.calcite.sql.validate.SelectScope;
+import org.apache.calcite.sql.validate.SqlMonotonicity;
+import org.apache.calcite.sql.validate.SqlUserDefinedTableFunction;
+import org.apache.calcite.sql.validate.SqlUserDefinedTableMacro;
+import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
+import org.apache.calcite.sql.validate.SqlValidatorNamespace;
+import org.apache.calcite.sql.validate.SqlValidatorScope;
+import org.apache.calcite.sql.validate.SqlValidatorUtil;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.ImmutableIntList;
+import org.apache.calcite.util.NlsString;
+import org.apache.calcite.util.NumberUtil;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
+import org.apache.calcite.util.mapping.Mappings;
+import org.apache.calcite.util.trace.CalciteTrace;
 
 import com.google.common.base.Function;
-import com.google.common.collect.*;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
-import static org.eigenbase.sql.SqlUtil.stripAs;
-import static org.eigenbase.util.Static.RESOURCE;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static org.apache.calcite.sql.SqlUtil.stripAs;
+import static org.apache.calcite.util.Static.RESOURCE;
 
 /**
- * Converts a SQL parse tree (consisting of {@link org.eigenbase.sql.SqlNode}
- * objects) into a relational algebra expression (consisting of
- * {@link org.eigenbase.rel.RelNode} objects).
+ * Converts a SQL parse tree (consisting of
+ * {@link org.apache.calcite.sql.SqlNode} objects) into a relational algebra
+ * expression (consisting of {@link org.apache.calcite.rel.RelNode} objects).
  *
  * <p>The public entry points are: {@link #convertQuery},
  * {@link #convertExpression(SqlNode)}.
@@ -63,7 +176,7 @@ public class SqlToRelConverter {
   //~ Static fields/initializers ---------------------------------------------
 
   protected static final Logger SQL2REL_LOGGER =
-      EigenbaseTrace.getSqlToRelTracer();
+      CalciteTrace.getSqlToRelTracer();
 
   private static final Function<SubQuery, SqlNode> FN =
       new Function<SubQuery, SqlNode>() {
@@ -273,19 +386,20 @@ public class SqlToRelConverter {
    * convert method.
    *
    * @param enabled true for immediate conversion (the default); false to
-   *                generate logical TableAccessRel instances
+   *                generate logical LogicalTableScan instances
    */
   public void enableTableAccessConversion(boolean enabled) {
     shouldConvertTableAccess = enabled;
   }
 
   /**
-   * Controls whether instances of {@link ValuesRel} are generated. These may
-   * not be supported by all physical implementations. To have any effect,
+   * Controls whether instances of
+   * {@link org.apache.calcite.rel.logical.LogicalValues} are generated. These
+   * may not be supported by all physical implementations. To have any effect,
    * this must be called before any convert method.
    *
-   * @param enabled true to allow ValuesRel to be generated (the default);
-   *                false to force substitution of ProjectRel+OneRowRel instead
+   * @param enabled true to allow LogicalValues to be generated (the default);
+   *                false to force substitution of Project+OneRow instead
    */
   public void enableValuesRelCreation(boolean enabled) {
     shouldCreateValuesRel = enabled;
@@ -303,9 +417,8 @@ public class SqlToRelConverter {
         RelDataType validatedRowType =
             validator.getValidatedNodeType(query);
         validatedRowType = uniquifyFields(validatedRowType);
-        throw Util.newInternal(
-            "Conversion to relational algebra failed to preserve "
-            + "datatypes:\n"
+        throw Util.newInternal("Conversion to relational algebra failed to "
+            + "preserve datatypes:\n"
             + "validated type:\n"
             + validatedRowType.getFullTypeString()
             + "\nconverted type:\n"
@@ -512,10 +625,10 @@ public class SqlToRelConverter {
    * Having translated 'SELECT ... FROM ... [GROUP BY ...] [HAVING ...]', adds
    * a relational expression to make the results unique.
    *
-   * <p>If the SELECT clause contains duplicate expressions, adds {@link
-   * ProjectRel}s so that we are grouping on the minimal set of keys. The
-   * performance gain isn't huge, but it is difficult to detect these
-   * duplicate expressions later.
+   * <p>If the SELECT clause contains duplicate expressions, adds
+   * {@link org.apache.calcite.rel.logical.LogicalProject}s so that we are
+   * grouping on the minimal set of keys. The performance gain isn't huge, but
+   * it is difficult to detect these duplicate expressions later.
    *
    * @param bb               Blackboard
    * @param checkForDupExprs Check for duplicate expressions
@@ -528,8 +641,8 @@ public class SqlToRelConverter {
     // Then dups will be {[2, 0]}
     // and oldToNew will be {[0, 0], [1, 1], [2, 0], [3, 2]}
     RelNode rel = bb.root;
-    if (checkForDupExprs && (rel instanceof ProjectRel)) {
-      ProjectRel project = (ProjectRel) rel;
+    if (checkForDupExprs && (rel instanceof LogicalProject)) {
+      LogicalProject project = (LogicalProject) rel;
       final List<RexNode> projectExprs = project.getProjects();
       List<Integer> origins = new ArrayList<Integer>();
       int dupCount = 0;
@@ -557,12 +670,12 @@ public class SqlToRelConverter {
         }
       }
       rel =
-          new ProjectRel(
+          new LogicalProject(
               cluster,
               rel,
               Pair.left(newProjects),
               Pair.right(newProjects),
-              ProjectRel.Flags.BOXED);
+              LogicalProject.Flags.BOXED);
 
       bb.root = rel;
       distinctify(bb, false);
@@ -582,12 +695,12 @@ public class SqlToRelConverter {
       }
 
       rel =
-          new ProjectRel(
+          new LogicalProject(
               cluster,
               rel,
               Pair.left(undoProjects),
               Pair.right(undoProjects),
-              ProjectRel.Flags.BOXED);
+              LogicalProject.Flags.BOXED);
 
       bb.setRoot(
           rel,
@@ -647,7 +760,7 @@ public class SqlToRelConverter {
 
     // Create a sorter using the previously constructed collations.
     bb.setRoot(
-        new SortRel(
+        new Sort(
             cluster,
             cluster.traitSetOf(Convention.NONE, collation),
             bb.root,
@@ -667,14 +780,14 @@ public class SqlToRelConverter {
         exprs.add(rexBuilder.makeInputRef(bb.root, i));
       }
       bb.setRoot(
-          new ProjectRel(
+          new LogicalProject(
               cluster,
               cluster.traitSetOf(RelCollationImpl.PRESERVE),
               bb.root,
               exprs,
               cluster.getTypeFactory().createStructType(
                   rowType.getFieldList().subList(0, fieldCount)),
-              ProjectRelBase.Flags.BOXED),
+              Project.Flags.BOXED),
           false);
     }
   }
@@ -919,15 +1032,15 @@ public class SqlToRelConverter {
         final RelNode seek = converted.left.getInput(0); // fragile
         final int keyCount = leftKeys.size();
         final List<Integer> args = ImmutableIntList.range(0, keyCount);
-        AggregateRel aggregate =
-            new AggregateRel(cluster, seek, BitSets.of(),
+        LogicalAggregate aggregate =
+            new LogicalAggregate(cluster, seek, BitSets.of(),
                 ImmutableList.of(
                     new AggregateCall(SqlStdOperatorTable.COUNT, false,
                         ImmutableList.<Integer>of(), longType, null),
                     new AggregateCall(SqlStdOperatorTable.COUNT, false,
                         args, longType, null)));
-        JoinRel join =
-            new JoinRel(cluster, bb.root, aggregate,
+        LogicalJoin join =
+            new LogicalJoin(cluster, bb.root, aggregate,
                 rexBuilder.makeLiteral(true), JoinRelType.INNER,
                 ImmutableSet.<String>of());
         bb.setRoot(join, false);
@@ -1041,9 +1154,9 @@ public class SqlToRelConverter {
       // cross join (select count(*) as c, count(deptno) as ck from v) as ct
       // left join (select distinct deptno, true as i from v) as dt
       //   on e.deptno = dt.deptno
-      final JoinRelBase join = (JoinRelBase) root;
-      final ProjectRelBase left = (ProjectRelBase) join.getLeft();
-      final RelNode leftLeft = ((JoinRelBase) left.getInput(0)).getLeft();
+      final Join join = (Join) root;
+      final Project left = (Project) join.getLeft();
+      final RelNode leftLeft = ((Join) left.getInput(0)).getLeft();
       final int leftLeftCount = leftLeft.getRowType().getFieldCount();
       final RelDataType nullableBooleanType =
           typeFactory.createTypeWithNullability(
@@ -1234,9 +1347,10 @@ public class SqlToRelConverter {
   /**
    * Gets the list size threshold under which {@link #convertInToOr} is used.
    * Lists of this size or greater will instead be converted to use a join
-   * against an inline table ({@link ValuesRel}) rather than a predicate. A
-   * threshold of 0 forces usage of an inline table in all cases; a threshold
-   * of Integer.MAX_VALUE forces usage of OR in all cases
+   * against an inline table
+   * ({@link org.apache.calcite.rel.logical.LogicalValues}) rather than a
+   * predicate. A threshold of 0 forces usage of an inline table in all cases; a
+   * threshold of Integer.MAX_VALUE forces usage of OR in all cases
    *
    * @return threshold, default 20
    */
@@ -1305,10 +1419,10 @@ public class SqlToRelConverter {
       boolean allowLiteralsOnly,
       RelDataType targetRowType) {
     // NOTE jvs 30-Apr-2006: We combine all rows consisting entirely of
-    // literals into a single ValuesRel; this gives the optimizer a smaller
+    // literals into a single LogicalValues; this gives the optimizer a smaller
     // input tree.  For everything else (computed expressions, row
     // subqueries), we union each row in as a projection on top of a
-    // OneRowRel.
+    // LogicalOneRow.
 
     final List<List<RexLiteral>> tupleList =
         new ArrayList<List<RexLiteral>>();
@@ -1375,24 +1489,24 @@ public class SqlToRelConverter {
       }
       unionInputs.add(convertRowConstructor(bb, call));
     }
-    ValuesRel valuesRel =
-        new ValuesRel(
+    LogicalValues values =
+        new LogicalValues(
             cluster,
             rowType,
             tupleList);
     RelNode resultRel;
     if (unionInputs.isEmpty()) {
-      resultRel = valuesRel;
+      resultRel = values;
     } else {
       if (!tupleList.isEmpty()) {
-        unionInputs.add(valuesRel);
+        unionInputs.add(values);
       }
-      UnionRel unionRel =
-          new UnionRel(
+      LogicalUnion union =
+          new LogicalUnion(
               cluster,
               unionInputs,
               true);
-      resultRel = unionRel;
+      resultRel = union;
     }
     leaves.add(resultRel);
     return resultRel;
@@ -1411,7 +1525,7 @@ public class SqlToRelConverter {
     if (type.isStruct()) {
       // null literals for weird stuff like UDT's need
       // special handling during type flattening, so
-      // don't use ValuesRel for those
+      // don't use LogicalValues for those
       return null;
     }
 
@@ -1426,7 +1540,7 @@ public class SqlToRelConverter {
       assert RexLiteral.isNullLiteral(child);
 
       // NOTE jvs 22-Nov-2006:  we preserve type info
-      // in ValuesRel digest, so it's OK to lose it here
+      // in LogicalValues digest, so it's OK to lose it here
       return (RexLiteral) child;
     }
 
@@ -1724,7 +1838,7 @@ public class SqlToRelConverter {
                 tableSampleSpec.getSamplePercentage(),
                 tableSampleSpec.isRepeatable(),
                 tableSampleSpec.getRepeatableSeed());
-        bb.setRoot(new SamplingRel(cluster, bb.root, params), false);
+        bb.setRoot(new Sample(cluster, bb.root, params), false);
       } else {
         throw Util.newInternal(
             "unknown TABLESAMPLE type: " + sampleSpec);
@@ -1751,7 +1865,7 @@ public class SqlToRelConverter {
       if (shouldConvertTableAccess) {
         tableRel = toRel(table);
       } else {
-        tableRel = new TableAccessRel(cluster, table);
+        tableRel = new LogicalTableScan(cluster, table);
       }
       bb.setRoot(tableRel, true);
       if (usedDataset[0]) {
@@ -1824,15 +1938,15 @@ public class SqlToRelConverter {
       replaceSubqueries(bb, node, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
       final RelNode childRel =
           RelOptUtil.createProject(
-              (null != bb.root) ? bb.root : new OneRowRel(cluster),
+              (null != bb.root) ? bb.root : new LogicalOneRow(cluster),
               Collections.singletonList(bb.convertExpression(node)),
               Collections.singletonList(validator.deriveAlias(node, 0)),
               true);
 
-      UncollectRel uncollectRel =
-          new UncollectRel(cluster, cluster.traitSetOf(Convention.NONE),
+      Uncollect uncollect =
+          new Uncollect(cluster, cluster.traitSetOf(Convention.NONE),
               childRel);
-      bb.setRoot(uncollectRel, true);
+      bb.setRoot(uncollect, true);
       return;
 
     case COLLECTION_TABLE:
@@ -1867,7 +1981,7 @@ public class SqlToRelConverter {
     replaceSubqueries(bb, call, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
 
     // Expand table macro if possible. It's more efficient than
-    // TableFunctionRel.
+    // LogicalTableFunctionScan.
     if (operator instanceof SqlUserDefinedTableMacro) {
       final SqlUserDefinedTableMacro udf =
           (SqlUserDefinedTableMacro) operator;
@@ -1892,8 +2006,8 @@ public class SqlToRelConverter {
     final List<RelNode> inputs = bb.retrieveCursors();
     Set<RelColumnMapping> columnMappings =
         getColumnMappings(operator);
-    TableFunctionRel callRel =
-        new TableFunctionRel(
+    LogicalTableFunctionScan callRel =
+        new LogicalTableFunctionScan(
             cluster,
             inputs,
             rexCall,
@@ -1907,7 +2021,7 @@ public class SqlToRelConverter {
   protected void afterTableFunction(
       SqlToRelConverter.Blackboard bb,
       SqlCall call,
-      TableFunctionRel callRel) {
+      LogicalTableFunctionScan callRel) {
   }
 
   private Set<RelColumnMapping> getColumnMappings(SqlOperator op) {
@@ -2011,7 +2125,7 @@ public class SqlToRelConverter {
       }
 
       if (!correlations.isEmpty()) {
-        return new CorrelatorRel(
+        return new Correlator(
             rightRel.getCluster(),
             leftRel,
             rightRel,
@@ -2035,13 +2149,11 @@ public class SqlToRelConverter {
       leftRel = RelOptUtil.createProject(
           leftRel,
           new AbstractList<Pair<RexNode, String>>() {
-            @Override
-            public int size() {
+            @Override public int size() {
               return leftCount + extraLeftExprs.size();
             }
 
-            @Override
-            public Pair<RexNode, String> get(int index) {
+            @Override public Pair<RexNode, String> get(int index) {
               if (index < leftCount) {
                 RelDataTypeField field = fields.get(index);
                 return Pair.<RexNode, String>of(
@@ -2062,13 +2174,11 @@ public class SqlToRelConverter {
       rightRel = RelOptUtil.createProject(
           rightRel,
           new AbstractList<Pair<RexNode, String>>() {
-            @Override
-            public int size() {
+            @Override public int size() {
               return rightCount + extraRightExprs.size();
             }
 
-            @Override
-            public Pair<RexNode, String> get(int index) {
+            @Override public Pair<RexNode, String> get(int index) {
               if (index < rightCount) {
                 RelDataTypeField field = fields.get(index);
                 return Pair.<RexNode, String>of(
@@ -2616,7 +2726,7 @@ public class SqlToRelConverter {
   }
 
   /**
-   * Creates an AggregateRel.
+   * Creates an Aggregate.
    *
    * <p>In case the aggregate rel changes the order in which it projects
    * fields, the <code>groupExprProjection</code> parameter is provided, and
@@ -2630,13 +2740,13 @@ public class SqlToRelConverter {
    * @param bb       Blackboard
    * @param groupSet Bit set of ordinals of grouping columns
    * @param aggCalls Array of calls to aggregate functions
-   * @return AggregateRel
+   * @return LogicalAggregate
    */
   protected RelNode createAggregate(
       Blackboard bb,
       BitSet groupSet,
       List<AggregateCall> aggCalls) {
-    return new AggregateRel(
+    return new LogicalAggregate(
         cluster,
         bb.root,
         groupSet,
@@ -2838,7 +2948,7 @@ public class SqlToRelConverter {
     }
     switch (call.getKind()) {
     case UNION:
-      return new UnionRel(
+      return new LogicalUnion(
           cluster,
           ImmutableList.of(left, right),
           all);
@@ -2846,7 +2956,7 @@ public class SqlToRelConverter {
     case INTERSECT:
       // TODO:  all
       if (!all) {
-        return new IntersectRel(
+        return new LogicalIntersect(
             cluster,
             ImmutableList.of(left, right),
             all);
@@ -2858,7 +2968,7 @@ public class SqlToRelConverter {
     case EXCEPT:
       // TODO:  all
       if (!all) {
-        return new MinusRel(
+        return new LogicalMinus(
             cluster,
             ImmutableList.of(left, right),
             all);
@@ -2893,16 +3003,16 @@ public class SqlToRelConverter {
           targetTable,
           catalogReader,
           massagedRel,
-          TableModificationRel.Operation.INSERT,
+          LogicalTableModify.Operation.INSERT,
           null,
           false);
     }
-    return new TableModificationRel(
+    return new LogicalTableModify(
         cluster,
         targetTable,
         catalogReader,
         massagedRel,
-        TableModificationRel.Operation.INSERT,
+        LogicalTableModify.Operation.INSERT,
         null,
         false);
   }
@@ -3045,12 +3155,12 @@ public class SqlToRelConverter {
   private RelNode convertDelete(SqlDelete call) {
     RelOptTable targetTable = getTargetTable(call);
     RelNode sourceRel = convertSelect(call.getSourceSelect());
-    return new TableModificationRel(
+    return new LogicalTableModify(
         cluster,
         targetTable,
         catalogReader,
         sourceRel,
-        TableModificationRel.Operation.DELETE,
+        LogicalTableModify.Operation.DELETE,
         null,
         false);
   }
@@ -3068,12 +3178,12 @@ public class SqlToRelConverter {
 
     RelNode sourceRel = convertSelect(call.getSourceSelect());
 
-    return new TableModificationRel(
+    return new LogicalTableModify(
         cluster,
         targetTable,
         catalogReader,
         sourceRel,
-        TableModificationRel.Operation.UPDATE,
+        LogicalTableModify.Operation.UPDATE,
         targetColumnNameList,
         false);
   }
@@ -3120,17 +3230,17 @@ public class SqlToRelConverter {
       // the column; or if the expressions directly map to the source
       // table
       level1InsertExprs =
-          ((ProjectRel) insertRel.getInput(0)).getProjects();
-      if (insertRel.getInput(0).getInput(0) instanceof ProjectRel) {
+          ((LogicalProject) insertRel.getInput(0)).getProjects();
+      if (insertRel.getInput(0).getInput(0) instanceof LogicalProject) {
         level2InsertExprs =
-            ((ProjectRel) insertRel.getInput(0).getInput(0))
+            ((LogicalProject) insertRel.getInput(0).getInput(0))
                 .getProjects();
       }
       nLevel1Exprs = level1InsertExprs.size();
     }
 
-    JoinRel joinRel = (JoinRel) mergeSourceRel.getInput(0);
-    int nSourceFields = joinRel.getLeft().getRowType().getFieldCount();
+    LogicalJoin join = (LogicalJoin) mergeSourceRel.getInput(0);
+    int nSourceFields = join.getLeft().getRowType().getFieldCount();
     List<RexNode> projects = new ArrayList<RexNode>();
     for (int level1Idx = 0; level1Idx < nLevel1Exprs; level1Idx++) {
       if ((level2InsertExprs != null)
@@ -3143,20 +3253,20 @@ public class SqlToRelConverter {
       }
     }
     if (updateCall != null) {
-      final ProjectRel project = (ProjectRel) mergeSourceRel;
+      final LogicalProject project = (LogicalProject) mergeSourceRel;
       projects.addAll(
           Util.skip(project.getProjects(), nSourceFields));
     }
 
     RelNode massagedRel =
-        RelOptUtil.createProject(joinRel, projects, null, true);
+        RelOptUtil.createProject(join, projects, null, true);
 
-    return new TableModificationRel(
+    return new LogicalTableModify(
         cluster,
         targetTable,
         catalogReader,
         massagedRel,
-        TableModificationRel.Operation.MERGE,
+        LogicalTableModify.Operation.MERGE,
         targetColumnNameList,
         false);
   }
@@ -3319,13 +3429,13 @@ public class SqlToRelConverter {
         joinList.add(lastList);
       }
       lastList = new ArrayList<SqlNode>();
-      CollectRel collectRel =
-          new CollectRel(
+      Collect collect =
+          new Collect(
               cluster,
               cluster.traitSetOf(Convention.NONE),
               input,
               validator.deriveAlias(call, i));
-      joinList.add(collectRel);
+      joinList.add(collect);
     }
 
     if (joinList.size() == 0) {
@@ -3354,7 +3464,7 @@ public class SqlToRelConverter {
 
         RelNode projRel =
             RelOptUtil.createProject(
-                new OneRowRel(cluster),
+                new LogicalOneRow(cluster),
                 selectList,
                 fieldNameList);
 
@@ -3386,7 +3496,7 @@ public class SqlToRelConverter {
    * @param joinType         Join type
    * @param variablesStopped Set of names of variables which are set by the
    *                         LHS and used by the RHS and are not available to
-   *                         nodes above this JoinRel in the tree
+   *                         nodes above this LogicalJoin in the tree
    * @return A relational expression representing a join
    */
   protected RelNode createJoin(
@@ -3395,7 +3505,7 @@ public class SqlToRelConverter {
       RexNode condition,
       JoinRelType joinType,
       Set<String> variablesStopped) {
-    return new JoinRel(
+    return new LogicalJoin(
         cluster,
         left,
         right,
@@ -3532,7 +3642,7 @@ public class SqlToRelConverter {
       Blackboard bb,
       SqlCall values,
       RelDataType targetRowType) {
-    // Attempt direct conversion to ValuesRel; if that fails, deal with
+    // Attempt direct conversion to LogicalValues; if that fails, deal with
     // fancy stuff like subqueries below.
     RelNode valuesRel =
         convertRowValues(
@@ -3562,7 +3672,7 @@ public class SqlToRelConverter {
       }
       RelNode in =
           (null == tmpBb.root)
-              ? new OneRowRel(cluster)
+              ? new LogicalOneRow(cluster)
               : tmpBb.root;
       unionRels.add(
           RelOptUtil.createProject(
@@ -3580,7 +3690,7 @@ public class SqlToRelConverter {
           true);
     } else {
       bb.setRoot(
-          new UnionRel(
+          new LogicalUnion(
               cluster,
               unionRels,
               true),
@@ -3721,14 +3831,14 @@ public class SqlToRelConverter {
           leftJoinKeys.add(origLeftInputCount + leftJoinKeys.size());
         }
 
-        ProjectRel newLeftInput =
-            (ProjectRel) RelOptUtil.createProject(
+        LogicalProject newLeftInput =
+            (LogicalProject) RelOptUtil.createProject(
                 root,
                 newLeftInputExpr,
                 null,
                 true);
 
-        // maintain the group by mapping in the new ProjectRel
+        // maintain the group by mapping in the new LogicalProject
         if (mapRootRelToFieldProjection.containsKey(root)) {
           mapRootRelToFieldProjection.put(
               newLeftInput,
@@ -3808,7 +3918,7 @@ public class SqlToRelConverter {
      */
     public void setRoot(RelNode root, boolean leaf) {
       setRoot(
-          Collections.singletonList(root), root, root instanceof JoinRel);
+          Collections.singletonList(root), root, root instanceof LogicalJoin);
       if (leaf) {
         leaves.add(root);
       }
@@ -3828,8 +3938,9 @@ public class SqlToRelConverter {
     }
 
     /**
-     * Notifies this Blackboard that the root just set using {@link
-     * #setRoot(RelNode, boolean)} was derived using dataset substitution.
+     * Notifies this Blackboard that the root just set using
+     * {@link #setRoot(RelNode, boolean)} was derived using dataset
+     * substitution.
      *
      * <p>The default implementation is not interested in such
      * notifications, and does nothing.
@@ -3854,8 +3965,7 @@ public class SqlToRelConverter {
       if (nameToNodeMap != null) {
         RexNode node = nameToNodeMap.get(name);
         if (node == null) {
-          throw Util.newInternal(
-              "Unknown identifier '" + name
+          throw Util.newInternal("Unknown identifier '" + name
               + "' encountered while expanding expression" + node);
         }
         return node;
@@ -3934,8 +4044,8 @@ public class SqlToRelConverter {
               Pair.of(rel, start[0]));
           start[0] += rel.getRowType().getFieldCount();
         } else {
-          if (rel instanceof JoinRel
-              || rel instanceof AggregateRel) {
+          if (rel instanceof LogicalJoin
+              || rel instanceof LogicalAggregate) {
             start[0] += systemFieldCount;
           }
           flatten(
@@ -4192,6 +4302,7 @@ public class SqlToRelConverter {
     }
   }
 
+  /** Deferred lookup. */
   private static class DeferredLookup {
     Blackboard bb;
     String originalRelName;
@@ -4283,8 +4394,8 @@ public class SqlToRelConverter {
         new SqlNodeList(SqlParserPos.ZERO);
 
     /**
-     * Input expressions for the group columns and aggregates, in {@link
-     * RexNode} format. The first elements of the list correspond to the
+     * Input expressions for the group columns and aggregates, in
+     * {@link RexNode} format. The first elements of the list correspond to the
      * elements in {@link #groupExprs}; the remaining elements are for
      * aggregates.
      */
@@ -4440,8 +4551,8 @@ public class SqlToRelConverter {
           bb.agg = this;
         }
 
-        final Aggregation aggregation =
-            (Aggregation) call.getOperator();
+        final SqlAggFunction aggFunction =
+            (SqlAggFunction) call.getOperator();
         RelDataType type = validator.deriveType(bb.scope, call);
         boolean distinct = false;
         SqlLiteral quantifier = call.getFunctionQuantifier();
@@ -4451,7 +4562,7 @@ public class SqlToRelConverter {
         }
         final AggregateCall aggCall =
             new AggregateCall(
-                aggregation,
+                aggFunction,
                 distinct,
                 args,
                 type,
@@ -4719,9 +4830,9 @@ public class SqlToRelConverter {
      * Returns the histogram operator corresponding to a given aggregate
      * function.
      *
-     * <p>For example, <code>getHistogramOp({@link
-     * SqlStdOperatorTable#MIN}}</code> returns {@link
-     * SqlStdOperatorTable#HISTOGRAM_MIN}.
+     * <p>For example, <code>getHistogramOp
+     *({@link SqlStdOperatorTable#MIN}}</code> returns
+     * {@link SqlStdOperatorTable#HISTOGRAM_MIN}.
      *
      * @param aggFunction An aggregate function
      * @return Its histogram function, or null

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
index 59b48d7..74fc92e 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
@@ -14,23 +14,62 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.sql2rel;
-
-import java.math.*;
-import java.util.*;
-
-import org.eigenbase.relopt.*;
-import org.eigenbase.reltype.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.*;
-import org.eigenbase.sql.fun.*;
-import org.eigenbase.sql.parser.*;
-import org.eigenbase.sql.type.*;
-import org.eigenbase.util.*;
-import org.eigenbase.util14.DateTimeUtil;
+package org.apache.calcite.sql2rel;
+
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexCallBinding;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexRangeRef;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.SqlAggFunction;
+import org.apache.calcite.sql.SqlBasicCall;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlIntervalLiteral;
+import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.SqlJdbcFunctionCall;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlNumericLiteral;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.fun.SqlArrayValueConstructor;
+import org.apache.calcite.sql.fun.SqlAvgAggFunction;
+import org.apache.calcite.sql.fun.SqlBetweenOperator;
+import org.apache.calcite.sql.fun.SqlCase;
+import org.apache.calcite.sql.fun.SqlDatetimeSubtractionOperator;
+import org.apache.calcite.sql.fun.SqlExtractFunction;
+import org.apache.calcite.sql.fun.SqlLiteralChainOperator;
+import org.apache.calcite.sql.fun.SqlMapValueConstructor;
+import org.apache.calcite.sql.fun.SqlMultisetQueryConstructor;
+import org.apache.calcite.sql.fun.SqlMultisetValueConstructor;
+import org.apache.calcite.sql.fun.SqlOverlapsOperator;
+import org.apache.calcite.sql.fun.SqlRowOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.util.DateTimeUtil;
+import org.apache.calcite.util.Util;
 
 import com.google.common.collect.ImmutableList;
 
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Standard implementation of {@link SqlRexConvertletTable}.
  */
@@ -155,11 +194,11 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
 
     // REVIEW jvs 24-Apr-2006: This only seems to be working from within a
     // windowed agg.  I have added an optimizer rule
-    // org.eigenbase.rel.rules.ReduceAggregatesRule which handles other
-    // cases post-translation.  The reason I did that was to defer the
-    // implementation decision; e.g. we may want to push it down to a
-    // foreign server directly rather than decomposed; decomposition is
-    // easier than recognition.
+    // org.apache.calcite.rel.rules.AggregateReduceFunctionsRule which handles
+    // other cases post-translation.  The reason I did that was to defer the
+    // implementation decision; e.g. we may want to push it down to a foreign
+    // server directly rather than decomposed; decomposition is easier than
+    // recognition.
 
     // Convert "avg(<expr>)" to "cast(sum(<expr>) / count(<expr>) as
     // <type>)". We don't need to handle the empty set specially, because
@@ -623,8 +662,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
     if (returnType == null) {
       RexCallBinding binding =
           new RexCallBinding(cx.getTypeFactory(), fun, exprs) {
-            @Override
-            public int getGroupCount() {
+            @Override public int getGroupCount() {
               return groupCount;
             }
           };
@@ -956,6 +994,8 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
     return cx.getRexBuilder().makeCast(resType, value);
   }
 
+  /** Convertlet that handles {@code AVG} and {@code VARIANCE}
+   * windowed aggregate functions. */
   private static class AvgVarianceConvertlet implements SqlRexConvertlet {
     private final SqlAvgAggFunction.Subtype subtype;
 
@@ -1067,6 +1107,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
     }
   }
 
+  /** Convertlet that handles {@code FLOOR} and {@code CEIL} functions. */
   private class FloorCeilConvertlet implements SqlRexConvertlet {
     private final boolean floor;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/sql2rel/SubqueryConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SubqueryConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SubqueryConverter.java
index 1f3a9e3..6145619 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SubqueryConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SubqueryConverter.java
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.sql2rel;
+package org.apache.calcite.sql2rel;
 
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.*;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.SqlCall;
 
 /**
  * SubqueryConverter provides the interface for classes that convert subqueries

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/sql2rel/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/package-info.java b/core/src/main/java/org/apache/calcite/sql2rel/package-info.java
index dcac14f..0b0aa01 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/package-info.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/package-info.java
@@ -18,6 +18,6 @@
 /**
  * Translates a SQL parse tree to relational expression.
  */
-package org.eigenbase.sql2rel;
+package org.apache.calcite.sql2rel;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/FrameworkConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/FrameworkConfig.java b/core/src/main/java/org/apache/calcite/tools/FrameworkConfig.java
index 98d0739..d3118dd 100644
--- a/core/src/main/java/org/apache/calcite/tools/FrameworkConfig.java
+++ b/core/src/main/java/org/apache/calcite/tools/FrameworkConfig.java
@@ -14,18 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.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.reltype.RelDataTypeSystem;
-import org.eigenbase.sql.SqlOperatorTable;
-import org.eigenbase.sql.parser.SqlParserImplFactory;
-import org.eigenbase.sql2rel.SqlRexConvertletTable;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.plan.Context;
+import org.apache.calcite.plan.RelOptCostFactory;
+import org.apache.calcite.plan.RelTraitDef;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.sql.SqlOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserImplFactory;
+import org.apache.calcite.sql2rel.SqlRexConvertletTable;
 
 import com.google.common.collect.ImmutableList;
 
@@ -60,7 +59,7 @@ public interface FrameworkConfig {
    *
    * <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}
+   * and {@link org.apache.calcite.tools.Planner#transform}
    * will only be called once.
    *
    * <p>However, consumers may also create programs
@@ -107,7 +106,7 @@ public interface FrameworkConfig {
 
   /**
    * Returns the PlannerContext that should be made available during planning by
-   * calling {@link org.eigenbase.relopt.RelOptPlanner#getContext()}.
+   * calling {@link org.apache.calcite.plan.RelOptPlanner#getContext()}.
    */
   Context getContext();
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/Frameworks.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/Frameworks.java b/core/src/main/java/org/apache/calcite/tools/Frameworks.java
index 7024343..4f835a5 100644
--- a/core/src/main/java/org/apache/calcite/tools/Frameworks.java
+++ b/core/src/main/java/org/apache/calcite/tools/Frameworks.java
@@ -14,29 +14,28 @@
  * 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 net.hydromatic.optiq.config.OptiqConnectionProperty;
-import net.hydromatic.optiq.jdbc.OptiqConnection;
-import net.hydromatic.optiq.jdbc.OptiqSchema;
-import net.hydromatic.optiq.prepare.OptiqPrepareImpl;
-import net.hydromatic.optiq.prepare.PlannerImpl;
-import net.hydromatic.optiq.server.OptiqServerStatement;
-
-import org.eigenbase.relopt.Context;
-import org.eigenbase.relopt.RelOptCluster;
-import org.eigenbase.relopt.RelOptCostFactory;
-import org.eigenbase.relopt.RelOptSchema;
-import org.eigenbase.relopt.RelTraitDef;
-import org.eigenbase.reltype.RelDataTypeSystem;
-import org.eigenbase.sql.SqlOperatorTable;
-import org.eigenbase.sql.fun.SqlStdOperatorTable;
-import org.eigenbase.sql.parser.SqlParserImplFactory;
-import org.eigenbase.sql.parser.impl.SqlParserImpl;
-import org.eigenbase.sql2rel.SqlRexConvertletTable;
-import org.eigenbase.sql2rel.StandardConvertletTable;
+package org.apache.calcite.tools;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.jdbc.CalciteConnection;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.plan.Context;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptCostFactory;
+import org.apache.calcite.plan.RelOptSchema;
+import org.apache.calcite.plan.RelTraitDef;
+import org.apache.calcite.prepare.CalcitePrepareImpl;
+import org.apache.calcite.prepare.PlannerImpl;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.server.CalciteServerStatement;
+import org.apache.calcite.sql.SqlOperatorTable;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserImplFactory;
+import org.apache.calcite.sql.parser.impl.SqlParserImpl;
+import org.apache.calcite.sql2rel.SqlRexConvertletTable;
+import org.apache.calcite.sql2rel.StandardConvertletTable;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
@@ -75,7 +74,7 @@ public class Frameworks {
   /** Piece of code to be run in a context where a planner and statement are
    * available. The planner is accessible from the {@code cluster} parameter, as
    * are several other useful objects. The connection and
-   * {@link net.hydromatic.optiq.DataContext} are accessible from the
+   * {@link org.apache.calcite.DataContext} are accessible from the
    * statement. */
   public abstract static class PrepareAction<R> {
     private final FrameworkConfig config;
@@ -94,7 +93,7 @@ public class Frameworks {
     }
 
     public abstract R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
-        SchemaPlus rootSchema, OptiqServerStatement statement);
+        SchemaPlus rootSchema, CalciteServerStatement statement);
   }
 
   /**
@@ -109,7 +108,7 @@ public class Frameworks {
     return withPrepare(
         new Frameworks.PrepareAction<R>(config) {
           public R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
-              SchemaPlus rootSchema, OptiqServerStatement statement) {
+              SchemaPlus rootSchema, CalciteServerStatement statement) {
             return action.apply(cluster, relOptSchema, rootSchema);
           }
         });
@@ -136,19 +135,19 @@ public class Frameworks {
    */
   public static <R> R withPrepare(PrepareAction<R> action) {
     try {
-      Class.forName("net.hydromatic.optiq.jdbc.Driver");
       final Properties info = new Properties();
       if (action.config.getTypeSystem() != RelDataTypeSystem.DEFAULT) {
-        info.setProperty(OptiqConnectionProperty.TYPE_SYSTEM.camelName(),
+        info.setProperty(CalciteConnectionProperty.TYPE_SYSTEM.camelName(),
             action.config.getTypeSystem().getClass().getName());
       }
       Connection connection =
           DriverManager.getConnection("jdbc:calcite:", info);
-      OptiqConnection optiqConnection =
-          connection.unwrap(OptiqConnection.class);
-      final OptiqServerStatement statement =
-          optiqConnection.createStatement().unwrap(OptiqServerStatement.class);
-      return new OptiqPrepareImpl().perform(statement, action);
+      CalciteConnection calciteConnection =
+          connection.unwrap(CalciteConnection.class);
+      final CalciteServerStatement statement =
+          calciteConnection.createStatement()
+              .unwrap(CalciteServerStatement.class);
+      return new CalcitePrepareImpl().perform(statement, action);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
@@ -161,7 +160,7 @@ public class Frameworks {
    *    definitions of tables, columns etc.
    */
   public static SchemaPlus createRootSchema(boolean addMetadataSchema) {
-    return OptiqSchema.createRootSchema(addMetadataSchema).plus();
+    return CalciteSchema.createRootSchema(addMetadataSchema).plus();
   }
 
   public static ConfigBuilder newConfigBuilder() {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/Planner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/Planner.java b/core/src/main/java/org/apache/calcite/tools/Planner.java
index 5b7e776..98c1649 100644
--- a/core/src/main/java/org/apache/calcite/tools/Planner.java
+++ b/core/src/main/java/org/apache/calcite/tools/Planner.java
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.relopt.RelTraitSet;
-import org.eigenbase.reltype.RelDataTypeFactory;
-import org.eigenbase.sql.SqlNode;
-import org.eigenbase.sql.parser.SqlParseException;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.parser.SqlParseException;
 
 /**
  * A fa&ccedil;ade that covers Calcite's query planning process: parse SQL,
@@ -38,7 +38,7 @@ public interface Planner {
    *
    * @param sql The SQL statement to parse.
    * @return The root node of the SQL parse tree.
-   * @throws org.eigenbase.sql.parser.SqlParseException on parse error
+   * @throws org.apache.calcite.sql.parser.SqlParseException on parse error
    */
   SqlNode parse(String sql) throws SqlParseException;
 
@@ -54,11 +54,11 @@ public interface Planner {
   /**
    * Converts a SQL parse tree into a tree of relational expressions.
    *
-   * <p>You must call {@link #validate(org.eigenbase.sql.SqlNode)} first.</p>
+   * <p>You must call {@link #validate(org.apache.calcite.sql.SqlNode)} first.
    *
    * @param sql The root node of the SQL parse tree.
    * @return The root node of the newly generated RelNode tree.
-   * @throws net.hydromatic.optiq.tools.RelConversionException if the node
+   * @throws org.apache.calcite.tools.RelConversionException if the node
    * cannot be converted or has not been validated
    */
   RelNode convert(SqlNode sql) throws RelConversionException;
@@ -78,7 +78,7 @@ public interface Planner {
    *                             at the termination of the planning cycle.
    * @param rel The root of the RelNode tree to convert.
    * @return The root of the new RelNode tree.
-   * @throws net.hydromatic.optiq.tools.RelConversionException on conversion
+   * @throws org.apache.calcite.tools.RelConversionException on conversion
    *     error
    */
   RelNode transform(int ruleSetIndex,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/Program.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/Program.java b/core/src/main/java/org/apache/calcite/tools/Program.java
index 04898e0..1bfa4cf 100644
--- a/core/src/main/java/org/apache/calcite/tools/Program.java
+++ b/core/src/main/java/org/apache/calcite/tools/Program.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.relopt.RelOptPlanner;
-import org.eigenbase.relopt.RelTraitSet;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelNode;
 
 /**
  * Program that transforms a relational expression into another relational
@@ -27,7 +27,7 @@ import org.eigenbase.relopt.RelTraitSet;
  * <p>A planner is a sequence of programs, each of which is sometimes called
  * a "phase".
  * The most typical program is an invocation of the volcano planner with a
- * particular {@link net.hydromatic.optiq.tools.RuleSet}.</p>
+ * particular {@link org.apache.calcite.tools.RuleSet}.</p>
  */
 public interface Program {
   RelNode run(RelOptPlanner planner, RelNode rel,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/Programs.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/Programs.java b/core/src/main/java/org/apache/calcite/tools/Programs.java
index 1364467..49c77ae 100644
--- a/core/src/main/java/org/apache/calcite/tools/Programs.java
+++ b/core/src/main/java/org/apache/calcite/tools/Programs.java
@@ -14,25 +14,54 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
-
-import net.hydromatic.optiq.prepare.OptiqPrepareImpl;
-import net.hydromatic.optiq.rules.java.JavaRules;
-
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.rel.metadata.ChainedRelMetadataProvider;
-import org.eigenbase.rel.metadata.DefaultRelMetadataProvider;
-import org.eigenbase.rel.metadata.RelMetadataProvider;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.relopt.hep.*;
+package org.apache.calcite.tools;
+
+import org.apache.calcite.adapter.enumerable.EnumerableRules;
+import org.apache.calcite.plan.RelOptCostImpl;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.plan.hep.HepMatchOrder;
+import org.apache.calcite.plan.hep.HepPlanner;
+import org.apache.calcite.plan.hep.HepProgram;
+import org.apache.calcite.plan.hep.HepProgramBuilder;
+import org.apache.calcite.prepare.CalcitePrepareImpl;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.metadata.ChainedRelMetadataProvider;
+import org.apache.calcite.rel.metadata.DefaultRelMetadataProvider;
+import org.apache.calcite.rel.metadata.RelMetadataProvider;
+import org.apache.calcite.rel.rules.AggregateExpandDistinctAggregatesRule;
+import org.apache.calcite.rel.rules.AggregateReduceFunctionsRule;
+import org.apache.calcite.rel.rules.AggregateStarTableRule;
+import org.apache.calcite.rel.rules.CalcMergeRule;
+import org.apache.calcite.rel.rules.FilterAggregateTransposeRule;
+import org.apache.calcite.rel.rules.FilterCalcMergeRule;
+import org.apache.calcite.rel.rules.FilterJoinRule;
+import org.apache.calcite.rel.rules.FilterProjectTransposeRule;
+import org.apache.calcite.rel.rules.FilterTableRule;
+import org.apache.calcite.rel.rules.FilterToCalcRule;
+import org.apache.calcite.rel.rules.JoinAssociateRule;
+import org.apache.calcite.rel.rules.JoinCommuteRule;
+import org.apache.calcite.rel.rules.JoinPushThroughJoinRule;
+import org.apache.calcite.rel.rules.JoinToMultiJoinRule;
+import org.apache.calcite.rel.rules.LoptOptimizeJoinRule;
+import org.apache.calcite.rel.rules.MultiJoinOptimizeBushyRule;
+import org.apache.calcite.rel.rules.ProjectCalcMergeRule;
+import org.apache.calcite.rel.rules.ProjectMergeRule;
+import org.apache.calcite.rel.rules.ProjectToCalcRule;
+import org.apache.calcite.rel.rules.SemiJoinRule;
+import org.apache.calcite.rel.rules.SortProjectTransposeRule;
+import org.apache.calcite.rel.rules.TableScanRule;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * Utilities for creating {@link Program}s.
@@ -47,21 +76,21 @@ public class Programs {
 
   public static final ImmutableList<RelOptRule> CALC_RULES =
       ImmutableList.of(
-          JavaRules.ENUMERABLE_CALC_RULE,
-          JavaRules.ENUMERABLE_FILTER_TO_CALC_RULE,
-          JavaRules.ENUMERABLE_PROJECT_TO_CALC_RULE,
-          MergeCalcRule.INSTANCE,
-          MergeFilterOntoCalcRule.INSTANCE,
-          MergeProjectOntoCalcRule.INSTANCE,
+          EnumerableRules.ENUMERABLE_CALC_RULE,
+          EnumerableRules.ENUMERABLE_FILTER_TO_CALC_RULE,
+          EnumerableRules.ENUMERABLE_PROJECT_TO_CALC_RULE,
+          CalcMergeRule.INSTANCE,
+          FilterCalcMergeRule.INSTANCE,
+          ProjectCalcMergeRule.INSTANCE,
           FilterToCalcRule.INSTANCE,
           ProjectToCalcRule.INSTANCE,
-          MergeCalcRule.INSTANCE,
+          CalcMergeRule.INSTANCE,
 
           // REVIEW jvs 9-Apr-2006: Do we still need these two?  Doesn't the
-          // combination of MergeCalcRule, FilterToCalcRule, and
+          // combination of CalcMergeRule, FilterToCalcRule, and
           // ProjectToCalcRule have the same effect?
-          MergeFilterOntoCalcRule.INSTANCE,
-          MergeProjectOntoCalcRule.INSTANCE);
+          FilterCalcMergeRule.INSTANCE,
+          ProjectCalcMergeRule.INSTANCE);
 
   /** Program that converts filters and projects to calcs. */
   public static final Program CALC_PROGRAM =
@@ -69,38 +98,38 @@ public class Programs {
 
   public static final ImmutableSet<RelOptRule> RULE_SET =
       ImmutableSet.of(
-          JavaRules.ENUMERABLE_JOIN_RULE,
-          JavaRules.ENUMERABLE_SEMI_JOIN_RULE,
-          JavaRules.ENUMERABLE_PROJECT_RULE,
-          JavaRules.ENUMERABLE_FILTER_RULE,
-          JavaRules.ENUMERABLE_AGGREGATE_RULE,
-          JavaRules.ENUMERABLE_SORT_RULE,
-          JavaRules.ENUMERABLE_LIMIT_RULE,
-          JavaRules.ENUMERABLE_UNION_RULE,
-          JavaRules.ENUMERABLE_INTERSECT_RULE,
-          JavaRules.ENUMERABLE_MINUS_RULE,
-          JavaRules.ENUMERABLE_TABLE_MODIFICATION_RULE,
-          JavaRules.ENUMERABLE_VALUES_RULE,
-          JavaRules.ENUMERABLE_WINDOW_RULE,
-          JavaRules.ENUMERABLE_ONE_ROW_RULE,
-          JavaRules.ENUMERABLE_EMPTY_RULE,
+          EnumerableRules.ENUMERABLE_JOIN_RULE,
+          EnumerableRules.ENUMERABLE_SEMI_JOIN_RULE,
+          EnumerableRules.ENUMERABLE_PROJECT_RULE,
+          EnumerableRules.ENUMERABLE_FILTER_RULE,
+          EnumerableRules.ENUMERABLE_AGGREGATE_RULE,
+          EnumerableRules.ENUMERABLE_SORT_RULE,
+          EnumerableRules.ENUMERABLE_LIMIT_RULE,
+          EnumerableRules.ENUMERABLE_UNION_RULE,
+          EnumerableRules.ENUMERABLE_INTERSECT_RULE,
+          EnumerableRules.ENUMERABLE_MINUS_RULE,
+          EnumerableRules.ENUMERABLE_TABLE_MODIFICATION_RULE,
+          EnumerableRules.ENUMERABLE_VALUES_RULE,
+          EnumerableRules.ENUMERABLE_WINDOW_RULE,
+          EnumerableRules.ENUMERABLE_ONE_ROW_RULE,
+          EnumerableRules.ENUMERABLE_EMPTY_RULE,
           SemiJoinRule.INSTANCE,
-          TableAccessRule.INSTANCE,
-          OptiqPrepareImpl.COMMUTE
-              ? CommutativeJoinRule.INSTANCE
-              : MergeProjectRule.INSTANCE,
+          TableScanRule.INSTANCE,
+          CalcitePrepareImpl.COMMUTE
+              ? JoinAssociateRule.INSTANCE
+              : ProjectMergeRule.INSTANCE,
           AggregateStarTableRule.INSTANCE,
           AggregateStarTableRule.INSTANCE2,
           FilterTableRule.INSTANCE,
-          PushFilterPastProjectRule.INSTANCE,
-          PushFilterPastJoinRule.FILTER_ON_JOIN,
-          RemoveDistinctAggregateRule.INSTANCE,
-          ReduceAggregatesRule.INSTANCE,
+          FilterProjectTransposeRule.INSTANCE,
+          FilterJoinRule.FILTER_ON_JOIN,
+          AggregateExpandDistinctAggregatesRule.INSTANCE,
+          AggregateReduceFunctionsRule.INSTANCE,
           FilterAggregateTransposeRule.INSTANCE,
-          SwapJoinRule.INSTANCE,
-          PushJoinThroughJoinRule.RIGHT,
-          PushJoinThroughJoinRule.LEFT,
-          PushSortPastProjectRule.INSTANCE);
+          JoinCommuteRule.INSTANCE,
+          JoinPushThroughJoinRule.RIGHT,
+          JoinPushThroughJoinRule.LEFT,
+          SortProjectTransposeRule.INSTANCE);
 
   // private constructor for utility class
   private Programs() {}
@@ -170,9 +199,9 @@ public class Programs {
   }
 
   /** Creates a program that invokes heuristic join-order optimization
-   * (via {@link org.eigenbase.rel.rules.ConvertMultiJoinRule},
-   * {@link org.eigenbase.rel.rules.MultiJoinRel} and
-   * {@link org.eigenbase.rel.rules.LoptOptimizeJoinRule})
+   * (via {@link org.apache.calcite.rel.rules.JoinToMultiJoinRule},
+   * {@link org.apache.calcite.rel.rules.MultiJoin} and
+   * {@link org.apache.calcite.rel.rules.LoptOptimizeJoinRule})
    * if there are 6 or more joins (7 or more relations). */
   public static Program heuristicJoinOrder(final Collection<RelOptRule> rules,
       final boolean bushy, final int minJoinCount) {
@@ -184,27 +213,27 @@ public class Programs {
         if (joinCount < minJoinCount) {
           program = ofRules(rules);
         } else {
-          // Create a program that gathers together joins as a MultiJoinRel.
+          // Create a program that gathers together joins as a MultiJoin.
           final HepProgram hep = new HepProgramBuilder()
-              .addRuleInstance(PushFilterPastJoinRule.FILTER_ON_JOIN)
+              .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
               .addMatchOrder(HepMatchOrder.BOTTOM_UP)
-              .addRuleInstance(ConvertMultiJoinRule.INSTANCE)
+              .addRuleInstance(JoinToMultiJoinRule.INSTANCE)
               .build();
           final Program program1 =
               of(hep, false, new DefaultRelMetadataProvider());
 
-          // Create a program that contains a rule to expand a MultiJoinRel
+          // Create a program that contains a rule to expand a MultiJoin
           // into heuristically ordered joins.
-          // We use the rule set passed in, but remove SwapJoinRule and
-          // PushJoinThroughJoinRule, because they cause exhaustive search.
+          // We use the rule set passed in, but remove JoinCommuteRule and
+          // JoinPushThroughJoinRule, because they cause exhaustive search.
           final List<RelOptRule> list = Lists.newArrayList(rules);
           list.removeAll(
-              ImmutableList.of(SwapJoinRule.INSTANCE,
-                  CommutativeJoinRule.INSTANCE,
-                  PushJoinThroughJoinRule.LEFT,
-                  PushJoinThroughJoinRule.RIGHT));
+              ImmutableList.of(JoinCommuteRule.INSTANCE,
+                  JoinAssociateRule.INSTANCE,
+                  JoinPushThroughJoinRule.LEFT,
+                  JoinPushThroughJoinRule.RIGHT));
           list.add(bushy
-              ? OptimizeBushyJoinRule.INSTANCE
+              ? MultiJoinOptimizeBushyRule.INSTANCE
               : LoptOptimizeJoinRule.INSTANCE);
           final Program program2 = ofRules(list);
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/RelConversionException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/RelConversionException.java b/core/src/main/java/org/apache/calcite/tools/RelConversionException.java
index c03aaef..6c1cecc 100644
--- a/core/src/main/java/org/apache/calcite/tools/RelConversionException.java
+++ b/core/src/main/java/org/apache/calcite/tools/RelConversionException.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
 /**
  * An Exception thrown when attempting conversion to a set of
- * {@link org.eigenbase.rel.RelNode}s.
+ * {@link org.apache.calcite.rel.RelNode}s.
  */
 public class RelConversionException extends Exception {
   /** Creates a RelConversionException with the specified detail message and

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/RuleSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/RuleSet.java b/core/src/main/java/org/apache/calcite/tools/RuleSet.java
index 8c467b1..b9b92ea 100644
--- a/core/src/main/java/org/apache/calcite/tools/RuleSet.java
+++ b/core/src/main/java/org/apache/calcite/tools/RuleSet.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
-import org.eigenbase.relopt.RelOptRule;
+import org.apache.calcite.plan.RelOptRule;
 
 /**
  * A set rules associated with a particular

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/RuleSets.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/RuleSets.java b/core/src/main/java/org/apache/calcite/tools/RuleSets.java
index 7d9857b..8a1cdc0 100644
--- a/core/src/main/java/org/apache/calcite/tools/RuleSets.java
+++ b/core/src/main/java/org/apache/calcite/tools/RuleSets.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
-import org.eigenbase.relopt.RelOptRule;
+import org.apache.calcite.plan.RelOptRule;
 
 import com.google.common.collect.ImmutableList;
 
@@ -26,7 +26,7 @@ import java.util.Iterator;
 /**
  * Utilities for creating and composing rule sets.
  *
- * @see net.hydromatic.optiq.tools.RuleSet
+ * @see org.apache.calcite.tools.RuleSet
  */
 public class RuleSets {
   private RuleSets() {
@@ -50,13 +50,11 @@ public class RuleSets {
       this.rules = rules;
     }
 
-    @Override
-    public int hashCode() {
+    @Override public int hashCode() {
       return rules.hashCode();
     }
 
-    @Override
-    public boolean equals(Object obj) {
+    @Override public boolean equals(Object obj) {
       return obj == this
           || obj instanceof ListRuleSet
           && rules.equals(((ListRuleSet) obj).rules);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/ValidationException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/ValidationException.java b/core/src/main/java/org/apache/calcite/tools/ValidationException.java
index 4046f9e..9651c71 100644
--- a/core/src/main/java/org/apache/calcite/tools/ValidationException.java
+++ b/core/src/main/java/org/apache/calcite/tools/ValidationException.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
 /**
  * An Exception thrown when attempting to validate a SQL parse tree.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/tools/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/package-info.java b/core/src/main/java/org/apache/calcite/tools/package-info.java
index 166259a..3273ae2 100644
--- a/core/src/main/java/org/apache/calcite/tools/package-info.java
+++ b/core/src/main/java/org/apache/calcite/tools/package-info.java
@@ -18,6 +18,6 @@
 /**
  * Provides utility classes.
  */
-package net.hydromatic.optiq.tools;
+package org.apache.calcite.tools;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/BarfingInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/BarfingInvocationHandler.java b/core/src/main/java/org/apache/calcite/util/BarfingInvocationHandler.java
index d83b057..94c50a6 100644
--- a/core/src/main/java/org/apache/calcite/util/BarfingInvocationHandler.java
+++ b/core/src/main/java/org/apache/calcite/util/BarfingInvocationHandler.java
@@ -14,9 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.util;
 
-import java.lang.reflect.*;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
 
 /**
  * A class derived from <code>BarfingInvocationHandler</code> handles a method

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/BasicDatetime.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/BasicDatetime.java b/core/src/main/java/org/apache/calcite/util/BasicDatetime.java
index f0f48ff..0d38bc0 100644
--- a/core/src/main/java/org/apache/calcite/util/BasicDatetime.java
+++ b/core/src/main/java/org/apache/calcite/util/BasicDatetime.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util14;
+package org.apache.calcite.util;
 
-import java.util.*;
+import java.util.TimeZone;
 
 /**
  * BasicDatetime is an interface for dates, times, or timestamps that can be
@@ -35,9 +35,9 @@ import java.util.*;
  *
  * <p>A zoned time represents a time that was created in a particular time zone.
  * It may contain date and/or time components that are valid when interpreted
- * relative to a specified time zone, according to a {@link java.util.Calendar
- * Calendar}. Jdbc types, such as {@link java.sql.Date} typically contain zoned
- * times.
+ * relative to a specified time zone, according to a
+ * {@link java.util.Calendar Calendar}. Jdbc types, such as
+ * {@link java.sql.Date} typically contain zoned times.
  */
 public interface BasicDatetime {
   //~ Methods ----------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/Benchmark.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/Benchmark.java b/core/src/main/java/org/apache/calcite/util/Benchmark.java
index 95aaa6c..b992427 100644
--- a/core/src/main/java/org/apache/calcite/util/Benchmark.java
+++ b/core/src/main/java/org/apache/calcite/util/Benchmark.java
@@ -14,15 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.util;
+
+import org.apache.calcite.linq4j.function.Function1;
 
 import java.text.MessageFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import net.hydromatic.linq4j.function.Function1;
-
 /**
  * Helps to run benchmarks by running the same task repeatedly and averaging
  * the running times.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/BitSets.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/BitSets.java b/core/src/main/java/org/apache/calcite/util/BitSets.java
index 0616fbb..0d79c85 100644
--- a/core/src/main/java/org/apache/calcite/util/BitSets.java
+++ b/core/src/main/java/org/apache/calcite/util/BitSets.java
@@ -14,12 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.util;
+package org.apache.calcite.util;
 
-import org.eigenbase.util.ImmutableIntList;
-import org.eigenbase.util.IntList;
-
-import java.util.*;
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 /**
  * Utility functions for {@link BitSet}.
@@ -265,7 +265,7 @@ public final class BitSets {
   }
 
   /** Populates a {@link BitSet} from an
-   *  {@link org.eigenbase.util.ImmutableIntList}. */
+   *  {@link ImmutableIntList}. */
   public static void populate(BitSet bitSet, ImmutableIntList list) {
     for (int i = 0; i < list.size(); i++) {
       bitSet.set(list.getInt(i));

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/BitString.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/BitString.java b/core/src/main/java/org/apache/calcite/util/BitString.java
index 1dc6a95..ab7e9c3 100644
--- a/core/src/main/java/org/apache/calcite/util/BitString.java
+++ b/core/src/main/java/org/apache/calcite/util/BitString.java
@@ -14,13 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.util;
 
-import java.math.*;
+import java.math.BigInteger;
 import java.util.List;
 
-import org.eigenbase.util14.*;
-
 /**
  * String of bits.
  *
@@ -28,12 +26,13 @@ import org.eigenbase.util14.*;
  * specified length. The length is preserved even if this means that the bit
  * string has leading '0's.
  *
- * <p>You can create a bit string from a string of 0s and 1s ({@link
- * #BitString(String, int)} or {@link #createFromBitString}), or from a string of
- * hex digits ({@link #createFromHexString}). You can convert it to a byte array
- * ({@link #getAsByteArray}), to a bit string ({@link #toBitString}), or to a
- * hex string ({@link #toHexString}). A utility method {@link
- * #toByteArrayFromBitString} converts a bit string directly to a byte array.
+ * <p>You can create a bit string from a string of 0s and 1s
+ * ({@link #BitString(String, int)} or {@link #createFromBitString}), or from a
+ * string of hex digits ({@link #createFromHexString}). You can convert it to a
+ * byte array ({@link #getAsByteArray}), to a bit string ({@link #toBitString}),
+ * or to a hex string ({@link #toHexString}). A utility method
+ * {@link #toByteArrayFromBitString} converts a bit string directly to a byte
+ * array.
  *
  * <p>This class is immutable: once created, none of the methods modify the
  * value.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/Bug.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/Bug.java b/core/src/main/java/org/apache/calcite/util/Bug.java
index 37a9db6..b851f27 100644
--- a/core/src/main/java/org/apache/calcite/util/Bug.java
+++ b/core/src/main/java/org/apache/calcite/util/Bug.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.util;
 
 /**
  * Holder for a list of constants describing which bugs which have not been
@@ -29,7 +29,7 @@ package org.eigenbase.util;
  * <pre>Statement stmt = connection.createStatement();
  * int rowCount = stmt.execute(
  *     "INSERT INTO FemaleEmps SELECT * FROM Emps WHERE gender = 'F'");
- * if (Bug.OPTIQ123_FIXED) {
+ * if (Bug.CALCITE_123_FIXED) {
  *    assertEquals(rowCount, 5);
  * }</pre>
  * </blockquote>

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java b/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
index 9ed9b8f..8ad1742 100644
--- a/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
+++ b/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
@@ -14,22 +14,47 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.util;
 
-import net.hydromatic.linq4j.*;
-import net.hydromatic.linq4j.expressions.FunctionExpression;
-import net.hydromatic.linq4j.expressions.Primitive;
-import net.hydromatic.linq4j.expressions.Types;
-import net.hydromatic.linq4j.function.*;
-
-import net.hydromatic.optiq.impl.interpreter.Row;
-import net.hydromatic.optiq.impl.java.ReflectiveSchema;
-import net.hydromatic.optiq.impl.jdbc.JdbcSchema;
-import net.hydromatic.optiq.runtime.*;
-
-import org.eigenbase.rel.metadata.Metadata;
-import org.eigenbase.rex.RexNode;
-import org.eigenbase.sql.SqlExplainLevel;
+import org.apache.calcite.DataContext;
+import org.apache.calcite.adapter.java.ReflectiveSchema;
+import org.apache.calcite.adapter.jdbc.JdbcSchema;
+import org.apache.calcite.interpreter.Row;
+import org.apache.calcite.linq4j.AbstractEnumerable;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.ExtendedEnumerable;
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.linq4j.function.EqualityComparer;
+import org.apache.calcite.linq4j.function.Function0;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.function.Function2;
+import org.apache.calcite.linq4j.function.Functions;
+import org.apache.calcite.linq4j.function.Predicate1;
+import org.apache.calcite.linq4j.function.Predicate2;
+import org.apache.calcite.linq4j.tree.FunctionExpression;
+import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.linq4j.tree.Types;
+import org.apache.calcite.rel.metadata.Metadata;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.runtime.BinarySearch;
+import org.apache.calcite.runtime.Bindable;
+import org.apache.calcite.runtime.Enumerables;
+import org.apache.calcite.runtime.FlatLists;
+import org.apache.calcite.runtime.ResultSetEnumerable;
+import org.apache.calcite.runtime.SortedMultiMap;
+import org.apache.calcite.runtime.SqlFunctions;
+import org.apache.calcite.runtime.Typed;
+import org.apache.calcite.schema.FilterableTable;
+import org.apache.calcite.schema.ModifiableTable;
+import org.apache.calcite.schema.QueryableTable;
+import org.apache.calcite.schema.ScannableTable;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Schemas;
+import org.apache.calcite.sql.SqlExplainLevel;
 
 import com.google.common.collect.ImmutableMap;
 
@@ -38,15 +63,34 @@ import java.lang.reflect.Method;
 import java.sql.ResultSet;
 import java.sql.Time;
 import java.sql.Timestamp;
-import java.util.*;
+import java.util.BitSet;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
 import javax.sql.DataSource;
 
-import static org.eigenbase.rel.metadata.BuiltInMetadata.*;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.ColumnOrigin;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.ColumnUniqueness;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.CumulativeCost;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.DistinctRowCount;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.ExplainVisibility;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.NonCumulativeCost;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.PercentageOriginalRows;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.PopulationSize;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.Predicates;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.RowCount;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.Selectivity;
+import static org.apache.calcite.rel.metadata.BuiltInMetadata.UniqueKeys;
 
 /**
- * Builtin methods.
+ * Built-in methods.
  */
-public enum BuiltinMethod {
+public enum BuiltInMethod {
   QUERYABLE_SELECT(Queryable.class, "select", FunctionExpression.class),
   QUERYABLE_AS_ENUMERABLE(Queryable.class, "asEnumerable"),
   QUERYABLE_TABLE_AS_QUERYABLE(QueryableTable.class, "asQueryable",
@@ -241,12 +285,12 @@ public enum BuiltinMethod {
   public final Method method;
   public final Constructor constructor;
 
-  public static final ImmutableMap<Method, BuiltinMethod> MAP;
+  public static final ImmutableMap<Method, BuiltInMethod> MAP;
 
   static {
-    final ImmutableMap.Builder<Method, BuiltinMethod> builder =
+    final ImmutableMap.Builder<Method, BuiltInMethod> builder =
         ImmutableMap.builder();
-    for (BuiltinMethod value : BuiltinMethod.values()) {
+    for (BuiltInMethod value : BuiltInMethod.values()) {
       if (value.method != null) {
         builder.put(value.method, value);
       }
@@ -254,15 +298,15 @@ public enum BuiltinMethod {
     MAP = builder.build();
   }
 
-  BuiltinMethod(Class clazz, String methodName, Class... argumentTypes) {
+  BuiltInMethod(Class clazz, String methodName, Class... argumentTypes) {
     this.method = Types.lookupMethod(clazz, methodName, argumentTypes);
     this.constructor = null;
   }
 
-  BuiltinMethod(Class clazz, Class... argumentTypes) {
+  BuiltInMethod(Class clazz, Class... argumentTypes) {
     this.method = null;
     this.constructor = Types.lookupConstructor(clazz, argumentTypes);
   }
 }
 
-// End BuiltinMethod.java
+// End BuiltInMethod.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/CalciteParserException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/CalciteParserException.java b/core/src/main/java/org/apache/calcite/util/CalciteParserException.java
index 49bfc9e..ff88c96 100644
--- a/core/src/main/java/org/apache/calcite/util/CalciteParserException.java
+++ b/core/src/main/java/org/apache/calcite/util/CalciteParserException.java
@@ -14,14 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util14;
+package org.apache.calcite.util;
 
 /**
- * This is a tagging interface to allow a {@link
- * org.eigenbase.sql.parser.SqlParseException} to be identified without adding a
+ * Tagging interface to allow a
+ * {@link org.apache.calcite.sql.parser.SqlParseException}
+ * to be identified without adding a
  * dependency on it from client-side code.
  */
-public interface EigenbaseParserException {
+public interface CalciteParserException {
 }
 
-// End EigenbaseParserException.java
+// End CalciteParserException.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/CalciteValidatorException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/CalciteValidatorException.java b/core/src/main/java/org/apache/calcite/util/CalciteValidatorException.java
index b03fb2b..2adc473 100644
--- a/core/src/main/java/org/apache/calcite/util/CalciteValidatorException.java
+++ b/core/src/main/java/org/apache/calcite/util/CalciteValidatorException.java
@@ -14,14 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util14;
+package org.apache.calcite.util;
 
 /**
- * This is a tagging interface to allow {@link
- * org.eigenbase.sql.validate.SqlValidatorException} to be identified without
+ * Tagging interface to allow a
+ * {@link org.apache.calcite.sql.validate.SqlValidatorException}
+ * to be identified without
  * adding a dependency on it from client-side code.
  */
-public interface EigenbaseValidatorException {
+public interface CalciteValidatorException {
 }
 
-// End EigenbaseValidatorException.java
+// End CalciteValidatorException.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/CancelFlag.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/CancelFlag.java b/core/src/main/java/org/apache/calcite/util/CancelFlag.java
index b088efe..b1f57b7 100644
--- a/core/src/main/java/org/apache/calcite/util/CancelFlag.java
+++ b/core/src/main/java/org/apache/calcite/util/CancelFlag.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.util;
 
 /**
  * CancelFlag is used to post and check cancellation requests.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/util/CastingList.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/CastingList.java b/core/src/main/java/org/apache/calcite/util/CastingList.java
index e9583cb..8bcf85c 100644
--- a/core/src/main/java/org/apache/calcite/util/CastingList.java
+++ b/core/src/main/java/org/apache/calcite/util/CastingList.java
@@ -14,19 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.util;
 
-import java.util.*;
+import java.util.AbstractList;
+import java.util.List;
 
 /**
  * Converts a list whose members are automatically down-cast to a given type.
  *
  * <p>If a member of the backing list is not an instanceof <code>E</code>, the
- * accessing method (such as {@link List#get}) will throw a {@link
- * ClassCastException}.
+ * accessing method (such as {@link List#get}) will throw a
+ * {@link ClassCastException}.
  *
  * <p>All modifications are automatically written to the backing list. Not
  * synchronized.
+ *
+ * @param <E> Element type
  */
 public class CastingList<E> extends AbstractList<E> implements List<E> {
   //~ Instance fields --------------------------------------------------------


Mime
View raw message