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/11/14 22:32:37 UTC

[29/58] [abbrv] [partial] incubator-calcite git commit: [CALCITE-306] Standardize code style for "import package.*; "

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexTransformer.java b/core/src/main/java/org/apache/calcite/rex/RexTransformer.java
index 167118e..307b466 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexTransformer.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexTransformer.java
@@ -14,14 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
+package org.apache.calcite.rex;
 
-import java.util.*;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeUtil;
 
-import org.eigenbase.reltype.*;
-import org.eigenbase.sql.*;
-import org.eigenbase.sql.fun.*;
-import org.eigenbase.sql.type.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * Takes a tree of {@link RexNode} objects and transforms it into another in one
@@ -51,7 +54,7 @@ public class RexTransformer {
     transformableOperators.add(SqlStdOperatorTable.AND);
 
     /** NOTE the OR operator is NOT missing.
-     * see {@link org.eigenbase.test.RexTransformerTest} */
+     * see {@link org.apache.calcite.test.RexTransformerTest} */
     transformableOperators.add(SqlStdOperatorTable.EQUALS);
     transformableOperators.add(SqlStdOperatorTable.NOT_EQUALS);
     transformableOperators.add(SqlStdOperatorTable.GREATER_THAN);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexUtil.java b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
index af365e1..286f8fb 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
@@ -14,20 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
-
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.reltype.*;
-import org.eigenbase.sql.*;
-import org.eigenbase.sql.fun.*;
-import org.eigenbase.sql.type.*;
-import org.eigenbase.util.*;
-import org.eigenbase.util.mapping.*;
-
-import net.hydromatic.linq4j.function.*;
+package org.apache.calcite.rex;
+
+import org.apache.calcite.linq4j.function.Predicate1;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelCollationImpl;
+import org.apache.calcite.rel.RelFieldCollation;
+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.sql.SqlAggFunction;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.apache.calcite.util.ControlFlowException;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
+import org.apache.calcite.util.mapping.Mappings;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
@@ -35,6 +41,11 @@ import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Utility methods concerning row-expressions.
  */
@@ -140,7 +151,7 @@ public class RexUtil {
    * <p>Examples:
    *
    * <ul>
-   * <li>For {@link org.eigenbase.rex.RexLiteral} Unknown, returns false.
+   * <li>For {@link org.apache.calcite.rex.RexLiteral} Unknown, returns false.
    * <li>For <code>CAST(NULL AS <i>type</i>)</code>, returns true if <code>
    * allowCast</code> is true, false otherwise.
    * <li>For <code>CAST(CAST(NULL AS <i>type</i>) AS <i>type</i>))</code>,
@@ -240,8 +251,8 @@ public class RexUtil {
   }
 
   /**
-   * Returns whether a given tree contains any {@link
-   * org.eigenbase.rex.RexFieldAccess} nodes.
+   * Returns whether a given tree contains any
+   * {@link org.apache.calcite.rex.RexFieldAccess} nodes.
    *
    * @param node a RexNode tree
    */
@@ -998,8 +1009,7 @@ public class RexUtil {
   public static RexNode shift(RexNode node, final int offset) {
     return node.accept(
         new RexShuttle() {
-          @Override
-          public RexNode visitInputRef(RexInputRef input) {
+          @Override public RexNode visitInputRef(RexInputRef input) {
             return new RexInputRef(input.getIndex() + offset, input.getType());
           }
         });
@@ -1012,8 +1022,7 @@ public class RexUtil {
   public static RexNode shift(RexNode node, final int start, final int offset) {
     return node.accept(
         new RexShuttle() {
-          @Override
-          public RexNode visitInputRef(RexInputRef input) {
+          @Override public RexNode visitInputRef(RexInputRef input) {
             final int index = input.getIndex();
             if (index < start) {
               return input;
@@ -1141,10 +1150,10 @@ public class RexUtil {
   }
 
   /**
-   * Walks over an expression and throws an exception if it finds an {@link
-   * RexInputRef} with an ordinal beyond the number of fields in the input row
-   * type, or a {@link RexLocalRef} with ordinal greater than that set using
-   * {@link #setLimit(int)}.
+   * Walks over an expression and throws an exception if it finds an
+   * {@link RexInputRef} with an ordinal beyond the number of fields in the
+   * input row type, or a {@link RexLocalRef} with ordinal greater than that set
+   * using {@link #setLimit(int)}.
    */
   private static class ForwardRefFinder extends RexVisitorImpl<Void> {
     private int limit = -1;
@@ -1175,6 +1184,8 @@ public class RexUtil {
       this.limit = limit;
     }
 
+    /** Thrown to abort a visit when we find an illegal forward reference.
+     * It changes control flow but is not considered an error. */
     static class IllegalForwardRefException extends ControlFlowException {
     }
   }
@@ -1207,7 +1218,7 @@ public class RexUtil {
     }
   }
 
-  /** Helps {@link org.eigenbase.rex.RexUtil#toCnf}. */
+  /** Helps {@link org.apache.calcite.rex.RexUtil#toCnf}. */
   private static class CnfHelper {
     final RexBuilder rexBuilder;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexVariable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexVariable.java b/core/src/main/java/org/apache/calcite/rex/RexVariable.java
index 79c2e69..717a569 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexVariable.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexVariable.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
+package org.apache.calcite.rex;
 
-import org.eigenbase.reltype.*;
+import org.apache.calcite.rel.type.RelDataType;
 
 /**
  * A row-expression which references a field.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexVisitor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexVisitor.java b/core/src/main/java/org/apache/calcite/rex/RexVisitor.java
index f22cc6e..fd3d6b6 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexVisitor.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexVisitor.java
@@ -14,14 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
+package org.apache.calcite.rex;
 
 /**
  * Visitor pattern for traversing a tree of {@link RexNode} objects.
  *
- * @see org.eigenbase.util.Glossary#VISITOR_PATTERN
+ * @see org.apache.calcite.util.Glossary#VISITOR_PATTERN
  * @see RexShuttle
  * @see RexVisitorImpl
+ *
+ * @param <R> Return type
  */
 public interface RexVisitor<R> {
   //~ Methods ----------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexVisitorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexVisitorImpl.java b/core/src/main/java/org/apache/calcite/rex/RexVisitorImpl.java
index 5c86a7c..fcc6ff7 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexVisitorImpl.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexVisitorImpl.java
@@ -14,13 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
+package org.apache.calcite.rex;
 
 import java.util.List;
 
 /**
  * Default implementation of {@link RexVisitor}, which visits each node but does
  * nothing while it's there.
+ *
+ * @param <R> Return type from each {@code visitXxx} method.
  */
 public class RexVisitorImpl<R> implements RexVisitor<R> {
   //~ Instance fields --------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexWindow.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexWindow.java b/core/src/main/java/org/apache/calcite/rex/RexWindow.java
index dfffbed..8fe3008 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexWindow.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexWindow.java
@@ -14,13 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
-
-import java.io.*;
-import java.util.List;
+package org.apache.calcite.rex;
 
 import com.google.common.collect.ImmutableList;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+
 /**
  * Specification of the window of rows over which a {@link RexOver} windowed
  * aggregate is evaluated.
@@ -42,8 +43,8 @@ public class RexWindow {
   /**
    * Creates a window.
    *
-   * <p>If you need to create a window from outside this package, use {@link
-   * RexBuilder#makeOver}.
+   * <p>If you need to create a window from outside this package, use
+   * {@link RexBuilder#makeOver}.
    */
   RexWindow(
       List<RexNode> partitionKeys,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/RexWindowBound.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexWindowBound.java b/core/src/main/java/org/apache/calcite/rex/RexWindowBound.java
index e866d2f..846f9dd 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexWindowBound.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexWindowBound.java
@@ -14,12 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rex;
+package org.apache.calcite.rex;
 
-import org.eigenbase.sql.SqlKind;
-import org.eigenbase.sql.SqlLiteral;
-import org.eigenbase.sql.SqlNode;
-import org.eigenbase.sql.SqlWindow;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlWindow;
 
 /**
  * Abstracts "XX PRECEDING/FOLLOWING" and "CURRENT ROW" bounds for windowed
@@ -94,7 +94,7 @@ public abstract class RexWindowBound {
   public int getOrderKey() { return -1; }
 
   /**
-   * Transforms the bound via {@link org.eigenbase.rex.RexVisitor}.
+   * Transforms the bound via {@link org.apache.calcite.rex.RexVisitor}.
    * @param visitor visitor to accept
    * @param <R> return type of the visitor
    * @return transformed bound
@@ -113,33 +113,27 @@ public abstract class RexWindowBound {
       this.node = node;
     }
 
-    @Override
-    public boolean isUnbounded() {
+    @Override public boolean isUnbounded() {
       return true;
     }
 
-    @Override
-    public boolean isPreceding() {
+    @Override public boolean isPreceding() {
       return SqlWindow.isUnboundedPreceding(node);
     }
 
-    @Override
-    public boolean isFollowing() {
+    @Override public boolean isFollowing() {
       return SqlWindow.isUnboundedFollowing(node);
     }
 
-    @Override
-    public String toString() {
+    @Override public String toString() {
       return ((SqlLiteral) node).getValue().toString();
     }
 
-    @Override
-    public int getOrderKey() {
+    @Override public int getOrderKey() {
       return isPreceding() ? 0 : 2;
     }
 
-    @Override
-    public boolean equals(Object o) {
+    @Override public boolean equals(Object o) {
       if (this == o) {
         return true;
       }
@@ -156,8 +150,7 @@ public abstract class RexWindowBound {
       return true;
     }
 
-    @Override
-    public int hashCode() {
+    @Override public int hashCode() {
       return node.hashCode();
     }
   }
@@ -166,28 +159,23 @@ public abstract class RexWindowBound {
    * Implements CURRENT ROW bound.
    */
   private static class RexWindowBoundCurrentRow extends RexWindowBound {
-    @Override
-    public boolean isCurrentRow() {
+    @Override public boolean isCurrentRow() {
       return true;
     }
 
-    @Override
-    public String toString() {
+    @Override public String toString() {
       return "CURRENT ROW";
     }
 
-    @Override
-    public int getOrderKey() {
+    @Override public int getOrderKey() {
       return 1;
     }
 
-    @Override
-    public boolean equals(Object obj) {
+    @Override public boolean equals(Object obj) {
       return getClass() == obj.getClass();
     }
 
-    @Override
-    public int hashCode() {
+    @Override public int hashCode() {
       return 123;
     }
   }
@@ -206,8 +194,8 @@ public abstract class RexWindowBound {
       RexCall call = (RexCall) node;
       this.offset = call.getOperands().get(0);
       this.sqlKind = call.getKind();
-      assert this.offset != null : "RexWindowBoundBounded offset should not be"
-                                   + " null";
+      assert this.offset != null
+          : "RexWindowBoundBounded offset should not be null";
     }
 
     private RexWindowBoundBounded(SqlKind sqlKind, RexNode offset) {
@@ -215,23 +203,19 @@ public abstract class RexWindowBound {
       this.offset = offset;
     }
 
-    @Override
-    public boolean isPreceding() {
+    @Override public boolean isPreceding() {
       return sqlKind == SqlKind.PRECEDING;
     }
 
-    @Override
-    public boolean isFollowing() {
+    @Override public boolean isFollowing() {
       return sqlKind == SqlKind.FOLLOWING;
     }
 
-    @Override
-    public RexNode getOffset() {
+    @Override public RexNode getOffset() {
       return offset;
     }
 
-    @Override
-    public <R> RexWindowBound accept(RexVisitor<R> visitor) {
+    @Override public <R> RexWindowBound accept(RexVisitor<R> visitor) {
       R r = offset.accept(visitor);
       if (r instanceof RexNode && r != offset) {
         return new RexWindowBoundBounded(sqlKind, (RexNode) r);
@@ -239,13 +223,11 @@ public abstract class RexWindowBound {
       return this;
     }
 
-    @Override
-    public String toString() {
+    @Override public String toString() {
       return offset.toString() + " " + sqlKind.toString();
     }
 
-    @Override
-    public boolean equals(Object o) {
+    @Override public boolean equals(Object o) {
       if (this == o) {
         return true;
       }
@@ -265,8 +247,7 @@ public abstract class RexWindowBound {
       return true;
     }
 
-    @Override
-    public int hashCode() {
+    @Override public int hashCode() {
       int result = sqlKind.hashCode();
       result = 31 * result + offset.hashCode();
       return result;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rex/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/package-info.java b/core/src/main/java/org/apache/calcite/rex/package-info.java
index 742790a..b776422 100644
--- a/core/src/main/java/org/apache/calcite/rex/package-info.java
+++ b/core/src/main/java/org/apache/calcite/rex/package-info.java
@@ -20,69 +20,65 @@
  *
  * <h2>Life-cycle</h2>
  *
- * <p>A {@link org.eigenbase.sql2rel.SqlToRelConverter} converts a SQL parse tree
- *     consisting of {@link org.eigenbase.sql.SqlNode} objects into a relational
- *     expression ({@link org.eigenbase.rel.RelNode}). Several kinds of nodes in
- *     this tree have row expressions ({@link org.eigenbase.rex.RexNode}).</p>
+ * <p>A {@link org.apache.calcite.sql2rel.SqlToRelConverter} converts a SQL
+ * parse tree consisting of {@link org.apache.calcite.sql.SqlNode} objects into
+ * a relational expression ({@link org.apache.calcite.rel.RelNode}). Several
+ * kinds of nodes in this tree have row expressions
+ * ({@link org.apache.calcite.rex.RexNode}).</p>
  *
  * <p>After the relational expression has been optimized, a
- *     {@link net.hydromatic.optiq.rules.java.JavaRelImplementor} converts it
- *     into to a plan. If the plan is a Java
- *     parse tree, row-expressions are translated into equivalent Java
- *     expressions.</p>
+ * {@link org.apache.calcite.adapter.enumerable.JavaRelImplementor} converts it
+ * into to a plan. If the plan is a Java parse tree, row-expressions are
+ * translated into equivalent Java expressions.</p>
  *
  * <h2>Expressions</h2>
  *
  *
  * <p>Every row-expression has a type. (Compare with
- *     {@link org.eigenbase.sql.SqlNode}, which is created before validation, and
- *     therefore types may not be available.)</p>
+ * {@link org.apache.calcite.sql.SqlNode}, which is created before validation,
+ * and therefore types may not be available.)</p>
  *
- * <p>Every node in the parse tree is a {@link org.eigenbase.rex.RexNode}.
+ * <p>Every node in the parse tree is a {@link org.apache.calcite.rex.RexNode}.
  *     Sub-types are:</p>
  * <ul>
- *     <li>{@link org.eigenbase.rex.RexLiteral} represents a boolean, numeric,
- *         string, or
- *         date constant, or the value <code>NULL</code>.
+ *     <li>{@link org.apache.calcite.rex.RexLiteral} represents a boolean,
+ *         numeric, string, or date constant, or the value <code>NULL</code>.
  *     </li>
- *     <li>{@link org.eigenbase.rex.RexVariable} represents a leaf of the tree. It
- *         has sub-types:
+ *     <li>{@link org.apache.calcite.rex.RexVariable} represents a leaf of the
+ *         tree. It has sub-types:
  *         <ul>
- *             <li>{@link org.eigenbase.rex.RexCorrelVariable} is a correlating
- *                 variable for
- *                 nested-loop joins
+ *             <li>{@link org.apache.calcite.rex.RexCorrelVariable} is a
+ *                 correlating variable for nested-loop joins
  *             </li>
- *             <li>{@link org.eigenbase.rex.RexInputRef} refers to a field of an
- *                 input
- *                 relational expression
+ *             <li>{@link org.apache.calcite.rex.RexInputRef} refers to a field
+ *                 of an input relational expression
  *             </li>
- *             <li>{@link org.eigenbase.rex.RexCall} is a call to an operator or
- *                 function.
- *                 By means of special operators, we can use this construct to
- *                 represent
- *                 virtually every non-leaf node in the tree.
+ *             <li>{@link org.apache.calcite.rex.RexCall} is a call to an
+ *                 operator or function.  By means of special operators, we can
+ *                 use this construct to represent virtually every non-leaf node
+ *                 in the tree.
  *             </li>
- *             <li>{@link org.eigenbase.rex.RexRangeRef} refers to a collection of
- *                 contiguous fields from an input relational expression. It
- *                 usually exists only
- *                 during translation.
+ *             <li>{@link org.apache.calcite.rex.RexRangeRef} refers to a
+ *                 collection of contiguous fields from an input relational
+ *                 expression. It usually exists only during translation.
  *             </li>
  *         </ul>
  *     </li>
  * </ul>
  *
  * <p>Expressions are generally
- *     created using a {@link org.eigenbase.rex.RexBuilder} factory.</p>
+ *     created using a {@link org.apache.calcite.rex.RexBuilder} factory.</p>
  *
  * <h2>Related packages</h2>
  * <ul>
- *     <li>{@link org.eigenbase.sql} SQL object model</li>
- *     <li>{@link org.eigenbase.relopt} Core classes, including {@link
- *         org.eigenbase.reltype.RelDataType} and {@link
- *         org.eigenbase.reltype.RelDataTypeFactory}.
- *     </li>
+ *     <li>{@link org.apache.calcite.sql} SQL object model</li>
+ *
+ *     <li>{@link org.apache.calcite.plan} Core classes, including
+ * {@link org.apache.calcite.rel.type.RelDataType} and
+ * {@link org.apache.calcite.rel.type.RelDataTypeFactory}.</li>
+ *
  * </ul>
  */
-package org.eigenbase.rex;
+package org.apache.calcite.rex;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rules/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rules/package-info.java b/core/src/main/java/org/apache/calcite/rules/package-info.java
deleted file mode 100644
index be29176..0000000
--- a/core/src/main/java/org/apache/calcite/rules/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Query optimizer rules.
- */
-package net.hydromatic.optiq.rules;
-
-// End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/AbstractCursor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/AbstractCursor.java b/core/src/main/java/org/apache/calcite/runtime/AbstractCursor.java
index 24d404b..547fec6 100644
--- a/core/src/main/java/org/apache/calcite/runtime/AbstractCursor.java
+++ b/core/src/main/java/org/apache/calcite/runtime/AbstractCursor.java
@@ -14,29 +14,42 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.avatica.*;
-
-import net.hydromatic.linq4j.expressions.Primitive;
-
-import org.eigenbase.util.Util;
-import org.eigenbase.util14.DateTimeUtil;
+import org.apache.calcite.avatica.ArrayImpl;
+import org.apache.calcite.avatica.ByteString;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.Cursor;
+import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.util.DateTimeUtil;
+import org.apache.calcite.util.Util;
 
 import java.io.InputStream;
 import java.io.Reader;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URL;
-import java.sql.*;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
 import java.sql.Date;
-import java.util.*;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Base class for implementing a cursor.
  *
  * <p>Derived class needs to provide {@link Getter} and can override
- * {@link net.hydromatic.avatica.Cursor.Accessor} implementations if it
+ * {@link org.apache.calcite.avatica.Cursor.Accessor} implementations if it
  * wishes.</p>
  */
 public abstract class AbstractCursor implements Cursor {
@@ -663,7 +676,7 @@ public abstract class AbstractCursor implements Cursor {
 
   /**
    * Accessor that assumes that the underlying value is an array of
-   * {@link net.hydromatic.avatica.ByteString} values;
+   * {@link org.apache.calcite.avatica.ByteString} values;
    * corresponds to {@link java.sql.Types#BINARY}
    * and {@link java.sql.Types#VARBINARY}.
    */
@@ -691,13 +704,11 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Object getObject() {
+    @Override public Object getObject() {
       return getDate(localCalendar);
     }
 
-    @Override
-    public Date getDate(Calendar calendar) {
+    @Override public Date getDate(Calendar calendar) {
       final int v = getInt();
       if (v == 0 && getter.wasNull()) {
         return null;
@@ -705,8 +716,7 @@ public abstract class AbstractCursor implements Cursor {
       return longToDate((long) v * DateTimeUtil.MILLIS_PER_DAY, calendar);
     }
 
-    @Override
-    public Timestamp getTimestamp(Calendar calendar) {
+    @Override public Timestamp getTimestamp(Calendar calendar) {
       final int v = getInt();
       if (v == 0 && getter.wasNull()) {
         return null;
@@ -714,8 +724,7 @@ public abstract class AbstractCursor implements Cursor {
       return longToTimestamp((long) v * DateTimeUtil.MILLIS_PER_DAY, calendar);
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final int v = getInt();
       if (v == 0 && wasNull()) {
         return null;
@@ -737,13 +746,11 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Object getObject() {
+    @Override public Object getObject() {
       return getTime(localCalendar);
     }
 
-    @Override
-    public Time getTime(Calendar calendar) {
+    @Override public Time getTime(Calendar calendar) {
       final int v = getInt();
       if (v == 0 && wasNull()) {
         return null;
@@ -751,8 +758,7 @@ public abstract class AbstractCursor implements Cursor {
       return intToTime(v, calendar);
     }
 
-    @Override
-    public Timestamp getTimestamp(Calendar calendar) {
+    @Override public Timestamp getTimestamp(Calendar calendar) {
       final long v = getLong();
       if (v == 0 && wasNull()) {
         return null;
@@ -760,8 +766,7 @@ public abstract class AbstractCursor implements Cursor {
       return longToTimestamp(v, calendar);
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final int v = getInt();
       if (v == 0 && wasNull()) {
         return null;
@@ -783,13 +788,11 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Object getObject() {
+    @Override public Object getObject() {
       return getTimestamp(localCalendar);
     }
 
-    @Override
-    public Timestamp getTimestamp(Calendar calendar) {
+    @Override public Timestamp getTimestamp(Calendar calendar) {
       final long v = getLong();
       if (v == 0 && wasNull()) {
         return null;
@@ -797,8 +800,7 @@ public abstract class AbstractCursor implements Cursor {
       return longToTimestamp(v, calendar);
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final long v = getLong();
       if (v == 0L && wasNull()) {
         return null;
@@ -820,8 +822,7 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Date getDate(Calendar calendar) {
+    @Override public Date getDate(Calendar calendar) {
       java.sql.Date date = (Date) getObject();
       if (date == null) {
         return null;
@@ -834,8 +835,7 @@ public abstract class AbstractCursor implements Cursor {
       return date;
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final int v = getInt();
       if (v == 0 && wasNull()) {
         return null;
@@ -843,8 +843,7 @@ public abstract class AbstractCursor implements Cursor {
       return dateAsString(v, null);
     }
 
-    @Override
-    public long getLong() {
+    @Override public long getLong() {
       Date date = getDate(null);
       return date == null
           ? 0L
@@ -865,8 +864,7 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Time getTime(Calendar calendar) {
+    @Override public Time getTime(Calendar calendar) {
       Time date  = (Time) getObject();
       if (date == null) {
         return null;
@@ -879,8 +877,7 @@ public abstract class AbstractCursor implements Cursor {
       return date;
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final int v = getInt();
       if (v == 0 && wasNull()) {
         return null;
@@ -888,8 +885,7 @@ public abstract class AbstractCursor implements Cursor {
       return timeAsString(v, null);
     }
 
-    @Override
-    public long getLong() {
+    @Override public long getLong() {
       Time time = getTime(null);
       return time == null ? 0L : (time.getTime() % DateTimeUtil.MILLIS_PER_DAY);
     }
@@ -908,8 +904,7 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Timestamp getTimestamp(Calendar calendar) {
+    @Override public Timestamp getTimestamp(Calendar calendar) {
       Timestamp date  = (Timestamp) getObject();
       if (date == null) {
         return null;
@@ -922,8 +917,7 @@ public abstract class AbstractCursor implements Cursor {
       return date;
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final long v = getLong();
       if (v == 0 && wasNull()) {
         return null;
@@ -931,8 +925,7 @@ public abstract class AbstractCursor implements Cursor {
       return timestampAsString(v, null);
     }
 
-    @Override
-    public long getLong() {
+    @Override public long getLong() {
       Timestamp timestamp = getTimestamp(null);
       return timestamp == null ? 0 : timestamp.getTime();
     }
@@ -952,8 +945,7 @@ public abstract class AbstractCursor implements Cursor {
       this.localCalendar = localCalendar;
     }
 
-    @Override
-    public Timestamp getTimestamp(Calendar calendar) {
+    @Override public Timestamp getTimestamp(Calendar calendar) {
       java.util.Date date  = (java.util.Date) getObject();
       if (date == null) {
         return null;
@@ -965,8 +957,7 @@ public abstract class AbstractCursor implements Cursor {
       return new Timestamp(v);
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       java.util.Date date  = (java.util.Date) getObject();
       if (date == null) {
         return null;
@@ -974,8 +965,7 @@ public abstract class AbstractCursor implements Cursor {
       return timestampAsString(date.getTime(), null);
     }
 
-    @Override
-    public long getLong() {
+    @Override public long getLong() {
       Timestamp timestamp = getTimestamp(localCalendar);
       return timestamp == null ? 0 : timestamp.getTime();
     }
@@ -994,8 +984,7 @@ public abstract class AbstractCursor implements Cursor {
       this.range = range;
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final int v = getInt();
       if (v == 0 && wasNull()) {
         return null;
@@ -1019,8 +1008,7 @@ public abstract class AbstractCursor implements Cursor {
       this.scale = scale;
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final long v = getLong();
       if (v == 0 && wasNull()) {
         return null;
@@ -1044,8 +1032,7 @@ public abstract class AbstractCursor implements Cursor {
       this.factory = factory;
     }
 
-    @Override
-    public Object getObject() {
+    @Override public Object getObject() {
       final Object object = super.getObject();
       if (object == null || object instanceof List) {
         return object;
@@ -1055,8 +1042,7 @@ public abstract class AbstractCursor implements Cursor {
       return Primitive.asList(object);
     }
 
-    @Override
-    public Array getArray() {
+    @Override public Array getArray() {
       final List list = (List) getObject();
       if (list == null) {
         return null;
@@ -1064,8 +1050,7 @@ public abstract class AbstractCursor implements Cursor {
       return new ArrayImpl(list, componentType, factory);
     }
 
-    @Override
-    public String getString() {
+    @Override public String getString() {
       final List o = (List) getObject();
       if (o == null) {
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/ArrayComparator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/ArrayComparator.java b/core/src/main/java/org/apache/calcite/runtime/ArrayComparator.java
index 59a4cda..d2f57ef 100644
--- a/core/src/main/java/org/apache/calcite/runtime/ArrayComparator.java
+++ b/core/src/main/java/org/apache/calcite/runtime/ArrayComparator.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 import com.google.common.collect.Ordering;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/ArrayEnumeratorCursor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/ArrayEnumeratorCursor.java b/core/src/main/java/org/apache/calcite/runtime/ArrayEnumeratorCursor.java
index a4c4bc3..5d09ae7 100644
--- a/core/src/main/java/org/apache/calcite/runtime/ArrayEnumeratorCursor.java
+++ b/core/src/main/java/org/apache/calcite/runtime/ArrayEnumeratorCursor.java
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Enumerator;
 
 /**
- * Implementation of {@link net.hydromatic.avatica.Cursor} on top of an
- * {@link net.hydromatic.linq4j.Enumerator} that
+ * Implementation of {@link org.apache.calcite.avatica.Cursor} on top of an
+ * {@link org.apache.calcite.linq4j.Enumerator} that
  * returns an array of {@link Object} for each row.
  */
 public class ArrayEnumeratorCursor extends EnumeratorCursor<Object[]> {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/BinarySearch.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/BinarySearch.java b/core/src/main/java/org/apache/calcite/runtime/BinarySearch.java
index 18ed28d..5311434 100644
--- a/core/src/main/java/org/apache/calcite/runtime/BinarySearch.java
+++ b/core/src/main/java/org/apache/calcite/runtime/BinarySearch.java
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.function.Function1;
-import net.hydromatic.linq4j.function.Functions;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.function.Functions;
 
 import java.util.Comparator;
 
@@ -230,7 +230,7 @@ public class BinarySearch {
       // code must guarantee the interval is reduced at each iteration
       assert imid > imin
           : "search interval should be reduced min=" + imin
-              + ", mid=" + imid + ", max=" + imax;
+          + ", mid=" + imid + ", max=" + imax;
       // note: 0 <= imin < imax implies imid will always be less than imax
 
       // reduce the search
@@ -271,3 +271,5 @@ public class BinarySearch {
     }
   }
 }
+
+// End BinarySearch.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Bindable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Bindable.java b/core/src/main/java/org/apache/calcite/runtime/Bindable.java
index 741e369..a5c62e9 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Bindable.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Bindable.java
@@ -14,11 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.Enumerable;
-
-import net.hydromatic.optiq.DataContext;
+import org.apache.calcite.DataContext;
+import org.apache.calcite.linq4j.Enumerable;
 
 /**
  * Statement that can be bound to a {@link DataContext} and then executed.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/CalciteContextException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteContextException.java b/core/src/main/java/org/apache/calcite/runtime/CalciteContextException.java
index c51e019..1dddc7b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteContextException.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteContextException.java
@@ -14,17 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.runtime;
 
 // NOTE:  This class gets compiled independently of everything else so that
 // resource generation can use reflection.  That means it must have no
-// dependencies on other Eigenbase code.
+// dependencies on other Calcite code.
 
 /**
  * Exception which contains information about the textual context of the causing
  * exception.
  */
-public class EigenbaseContextException extends EigenbaseException {
+public class CalciteContextException extends CalciteException {
   //~ Static fields/initializers ---------------------------------------------
 
   /**
@@ -49,18 +49,18 @@ public class EigenbaseContextException extends EigenbaseException {
   //~ Constructors -----------------------------------------------------------
 
   /**
-   * Creates a new EigenbaseContextException object. This constructor is for
+   * Creates a new CalciteContextException object. This constructor is for
    * use by the generated factory.
    *
    * @param message error message
    * @param cause   underlying cause, must not be null
    */
-  public EigenbaseContextException(String message, Throwable cause) {
+  public CalciteContextException(String message, Throwable cause) {
     this(message, cause, 0, 0, 0, 0);
   }
 
   /**
-   * Creates a new EigenbaseContextException object.
+   * Creates a new CalciteContextException object.
    *
    * @param message      error message
    * @param cause        underlying cause, must not be null
@@ -69,7 +69,7 @@ public class EigenbaseContextException extends EigenbaseException {
    * @param endPosLine   1-based end line number
    * @param endPosColumn 1-based end column number
    */
-  public EigenbaseContextException(
+  public CalciteContextException(
       String message,
       Throwable cause,
       int posLine,
@@ -82,14 +82,14 @@ public class EigenbaseContextException extends EigenbaseException {
   }
 
   /**
-   * Creates a new EigenbaseContextException object. This constructor is for
+   * Creates a new CalciteContextException object. This constructor is for
    * use by the generated factory.
    *
    * @param message   error message
    * @param cause     underlying cause, must not be null
    * @param inputText is the orginal SQL statement, may be null
    */
-  public EigenbaseContextException(
+  public CalciteContextException(
       String message,
       Throwable cause,
       String inputText) {
@@ -174,12 +174,11 @@ public class EigenbaseContextException extends EigenbaseException {
     this.originalStatement = originalStatement;
   }
 
-  @Override
-  public String getMessage() {
+  @Override public String getMessage() {
     // The superclass' message is the textual context information
     // for this exception, so we add in the underlying cause to the message
     return super.getMessage() + ": " + getCause().getMessage();
   }
 }
 
-// End EigenbaseContextException.java
+// End CalciteContextException.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/CalciteException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteException.java b/core/src/main/java/org/apache/calcite/runtime/CalciteException.java
index 2e69df1..387e8da 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteException.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteException.java
@@ -14,21 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.util;
+package org.apache.calcite.runtime;
 
-import java.util.logging.*;
+import java.util.logging.Logger;
 
 // NOTE:  This class gets compiled independently of everything else so that
 // resource generation can use reflection.  That means it must have no
-// dependencies on other Eigenbase code.
+// dependencies on other Calcite code.
 
 
 /**
  * Base class for all exceptions originating from Farrago.
  *
- * @see EigenbaseContextException
+ * @see CalciteContextException
  */
-public class EigenbaseException extends RuntimeException {
+public class CalciteException extends RuntimeException {
   //~ Static fields/initializers ---------------------------------------------
 
   /**
@@ -39,26 +39,26 @@ public class EigenbaseException extends RuntimeException {
   private static final long serialVersionUID = -1314522633397794178L;
 
   private static final Logger LOGGER =
-      Logger.getLogger(EigenbaseException.class.getName());
+      Logger.getLogger(CalciteException.class.getName());
 
   //~ Constructors -----------------------------------------------------------
 
   /**
-   * Creates a new EigenbaseException object.
+   * Creates a new CalciteException object.
    *
    * @param message error message
    * @param cause   underlying cause
    */
-  public EigenbaseException(
+  public CalciteException(
       String message,
       Throwable cause) {
     super(message, cause);
 
     // TODO: Force the caller to pass in a Logger as a trace argument for
     // better context.  Need to extend ResGen for this.
-    LOGGER.throwing("EigenbaseException", "constructor", this);
+    LOGGER.throwing("CalciteException", "constructor", this);
     LOGGER.severe(toString());
   }
 }
 
-// End EigenbaseException.java
+// End CalciteException.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
index 82b06a1..8b49f65 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
@@ -14,26 +14,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.resource;
+package org.apache.calcite.runtime;
 
-import org.eigenbase.sql.validate.SqlValidatorException;
-import org.eigenbase.util.EigenbaseContextException;
-import org.eigenbase.util.EigenbaseException;
+import org.apache.calcite.sql.validate.SqlValidatorException;
 
-import static org.eigenbase.resource.Resources.*;
+import static org.apache.calcite.runtime.Resources.BaseMessage;
+import static org.apache.calcite.runtime.Resources.ExInst;
+import static org.apache.calcite.runtime.Resources.ExInstWithCause;
+import static org.apache.calcite.runtime.Resources.Inst;
+import static org.apache.calcite.runtime.Resources.Property;
 
 /**
- * Compiler-checked resources for the Eigenbase project.
+ * Compiler-checked resources for the Calcite project.
  */
-public interface EigenbaseNewResource {
+public interface CalciteResource {
   @BaseMessage("line {0,number,#}, column {1,number,#}")
   Inst parserContext(int a0, int a1);
 
   @BaseMessage("Illegal {0} literal {1}: {2}")
-  ExInst<EigenbaseException> illegalLiteral(String a0, String a1, String a2);
+  ExInst<CalciteException> illegalLiteral(String a0, String a1, String a2);
 
   @BaseMessage("Length of identifier ''{0}'' must be less than or equal to {1,number,#} characters")
-  ExInst<EigenbaseException> identifierTooLong(String a0, int a1);
+  ExInst<CalciteException> identifierTooLong(String a0, int a1);
 
   @BaseMessage("not in format ''{0}''")
   Inst badFormat(String a0);
@@ -43,53 +45,53 @@ public interface EigenbaseNewResource {
 
   @BaseMessage("Illegal INTERVAL literal {0}; at {1}")
   @Property(name = "SQLSTATE", value = "42000")
-  ExInst<EigenbaseException> illegalIntervalLiteral(String a0, String a1);
+  ExInst<CalciteException> illegalIntervalLiteral(String a0, String a1);
 
   @BaseMessage("Illegal expression. Was expecting \"(DATETIME - DATETIME) INTERVALQUALIFIER\"")
-  ExInst<EigenbaseException> illegalMinusDate();
+  ExInst<CalciteException> illegalMinusDate();
 
   @BaseMessage("Illegal overlaps expression. Was expecting expression on the form \"(DATETIME, EXPRESSION) OVERLAPS (DATETIME, EXPRESSION)\"")
-  ExInst<EigenbaseException> illegalOverlaps();
+  ExInst<CalciteException> illegalOverlaps();
 
   @BaseMessage("Non-query expression encountered in illegal context")
-  ExInst<EigenbaseException> illegalNonQueryExpression();
+  ExInst<CalciteException> illegalNonQueryExpression();
 
   @BaseMessage("Query expression encountered in illegal context")
-  ExInst<EigenbaseException> illegalQueryExpression();
+  ExInst<CalciteException> illegalQueryExpression();
 
   @BaseMessage("CURSOR expression encountered in illegal context")
-  ExInst<EigenbaseException> illegalCursorExpression();
+  ExInst<CalciteException> illegalCursorExpression();
 
   @BaseMessage("ORDER BY unexpected")
-  ExInst<EigenbaseException> illegalOrderBy();
+  ExInst<CalciteException> illegalOrderBy();
 
   @BaseMessage("Illegal binary string {0}")
-  ExInst<EigenbaseException> illegalBinaryString(String a0);
+  ExInst<CalciteException> illegalBinaryString(String a0);
 
   @BaseMessage("''FROM'' without operands preceding it is illegal")
-  ExInst<EigenbaseException> illegalFromEmpty();
+  ExInst<CalciteException> illegalFromEmpty();
 
   @BaseMessage("ROW expression encountered in illegal context")
-  ExInst<EigenbaseException> illegalRowExpression();
+  ExInst<CalciteException> illegalRowExpression();
 
   @BaseMessage("TABLESAMPLE percentage must be between 0 and 100, inclusive")
   @Property(name = "SQLSTATE", value = "2202H")
-  ExInst<EigenbaseException> invalidSampleSize();
+  ExInst<CalciteException> invalidSampleSize();
 
   @BaseMessage("Unknown character set ''{0}''")
-  ExInst<EigenbaseException> unknownCharacterSet(String a0);
+  ExInst<CalciteException> unknownCharacterSet(String a0);
 
   @BaseMessage("Failed to encode ''{0}'' in character set ''{1}''")
-  ExInst<EigenbaseException> charsetEncoding(String a0, String a1);
+  ExInst<CalciteException> charsetEncoding(String a0, String a1);
 
   @BaseMessage("UESCAPE ''{0}'' must be exactly one character")
-  ExInst<EigenbaseException> unicodeEscapeCharLength(String a0);
+  ExInst<CalciteException> unicodeEscapeCharLength(String a0);
 
   @BaseMessage("UESCAPE ''{0}'' may not be hex digit, whitespace, plus sign, or double quote")
-  ExInst<EigenbaseException> unicodeEscapeCharIllegal(String a0);
+  ExInst<CalciteException> unicodeEscapeCharIllegal(String a0);
 
   @BaseMessage("UESCAPE cannot be specified without Unicode literal introducer")
-  ExInst<EigenbaseException> unicodeEscapeUnexpected();
+  ExInst<CalciteException> unicodeEscapeUnexpected();
 
   @BaseMessage("Unicode escape sequence starting at character {0,number,#} is not exactly four hex digits")
   ExInst<SqlValidatorException> unicodeEscapeMalformed(int a0);
@@ -101,11 +103,11 @@ public interface EigenbaseNewResource {
   ExInst<SqlValidatorException> invalidArgCount(String a0, int a1);
 
   @BaseMessage("At line {0,number,#}, column {1,number,#}")
-  ExInstWithCause<EigenbaseContextException> validatorContextPoint(int a0,
+  ExInstWithCause<CalciteContextException> validatorContextPoint(int a0,
       int a1);
 
   @BaseMessage("From line {0,number,#}, column {1,number,#} to line {2,number,#}, column {3,number,#}")
-  ExInstWithCause<EigenbaseContextException> validatorContext(int a0, int a1,
+  ExInstWithCause<CalciteContextException> validatorContext(int a0, int a1,
       int a2,
       int a3);
 
@@ -186,11 +188,11 @@ public interface EigenbaseNewResource {
   ExInst<SqlValidatorException> illegalMixingOfTypes();
 
   @BaseMessage("Invalid compare. Comparing (collation, coercibility): ({0}, {1} with ({2}, {3}) is illegal")
-  ExInst<EigenbaseException> invalidCompare(String a0, String a1, String a2,
+  ExInst<CalciteException> invalidCompare(String a0, String a1, String a2,
       String a3);
 
   @BaseMessage("Invalid syntax. Two explicit different collations ({0}, {1}) are illegal")
-  ExInst<EigenbaseException> differentCollations(String a0, String a1);
+  ExInst<CalciteException> differentCollations(String a0, String a1);
 
   @BaseMessage("{0} is not comparable to {1}")
   ExInst<SqlValidatorException> typeNotComparable(String a0, String a1);
@@ -402,7 +404,7 @@ public interface EigenbaseNewResource {
   ExInst<SqlValidatorException> duplicateNameInColumnList(String a0);
 
   @BaseMessage("Internal error: {0}")
-  ExInst<EigenbaseException> internal(String a0);
+  ExInst<CalciteException> internal(String a0);
 
   @BaseMessage("Argument to function ''{0}'' must be a literal")
   ExInst<SqlValidatorException> argumentMustBeLiteral(String a0);
@@ -411,10 +413,10 @@ public interface EigenbaseNewResource {
   ExInst<SqlValidatorException> argumentMustBePositiveInteger(String a0);
 
   @BaseMessage("Validation Error: {0}")
-  ExInst<EigenbaseException> validationError(String a0);
+  ExInst<CalciteException> validationError(String a0);
 
   @BaseMessage("Locale ''{0}'' in an illegal format")
-  ExInst<EigenbaseException> illegalLocaleFormat(String a0);
+  ExInst<CalciteException> illegalLocaleFormat(String a0);
 
   @BaseMessage("Argument to function ''{0}'' must not be NULL")
   ExInst<SqlValidatorException> argumentMustNotBeNull(String a0);
@@ -426,27 +428,27 @@ public interface EigenbaseNewResource {
   ExInst<SqlValidatorException> dynamicParamIllegal();
 
   @BaseMessage("''{0}'' is not a valid boolean value")
-  ExInst<EigenbaseException> invalidBoolean(String a0);
+  ExInst<CalciteException> invalidBoolean(String a0);
 
   @BaseMessage("Argument to function ''{0}'' must be a valid precision between ''{1,number,#}'' and ''{2,number,#}''")
   ExInst<SqlValidatorException> argumentMustBeValidPrecision(String a0, int a1,
       int a2);
 
   @BaseMessage("Wrong arguments for table function ''{0}'' call. Expected ''{1}'', actual ''{2}''")
-  ExInst<EigenbaseException> illegalArgumentForTableFunctionCall(String a0,
+  ExInst<CalciteException> illegalArgumentForTableFunctionCall(String a0,
       String a1, String a2);
 
   @BaseMessage("''{0}'' is not a valid datetime format")
-  ExInst<EigenbaseException> invalidDatetimeFormat(String a0);
+  ExInst<CalciteException> invalidDatetimeFormat(String a0);
 
   @BaseMessage("Cannot explicitly insert value into IDENTITY column ''{0}'' which is ALWAYS GENERATED")
-  ExInst<EigenbaseException> insertIntoAlwaysGenerated(String a0);
+  ExInst<CalciteException> insertIntoAlwaysGenerated(String a0);
 
   @BaseMessage("Argument to function ''{0}'' must have a scale of 0")
-  ExInst<EigenbaseException> argumentMustHaveScaleZero(String a0);
+  ExInst<CalciteException> argumentMustHaveScaleZero(String a0);
 
   @BaseMessage("Statement preparation aborted")
-  ExInst<EigenbaseException> preparationAborted();
+  ExInst<CalciteException> preparationAborted();
 
   @BaseMessage("SELECT DISTINCT not supported")
   @Property(name = "FeatureDefinition", value = "SQL:2003 Part 2 Annex F")
@@ -482,7 +484,7 @@ public interface EigenbaseNewResource {
 
   @BaseMessage("Execution of a new autocommit statement while a cursor is still open on same connection is not supported")
   @Property(name = "FeatureDefinition", value = "Eigenbase-defined")
-  ExInst<EigenbaseException>
+  ExInst<CalciteException>
   sQLConformance_MultipleActiveAutocommitStatements();
 
   @BaseMessage("Descending sort (ORDER BY DESC) not supported")
@@ -491,7 +493,7 @@ public interface EigenbaseNewResource {
 
   @BaseMessage("Sharing of cached statement plans not supported")
   @Property(name = "FeatureDefinition", value = "Eigenbase-defined")
-  ExInst<EigenbaseException> sharedStatementPlans();
+  ExInst<CalciteException> sharedStatementPlans();
 
   @BaseMessage("TABLESAMPLE SUBSTITUTE not supported")
   @Property(name = "FeatureDefinition", value = "Eigenbase-defined")
@@ -499,15 +501,15 @@ public interface EigenbaseNewResource {
 
   @BaseMessage("Personality does not maintain table''s row count in the catalog")
   @Property(name = "FeatureDefinition", value = "Eigenbase-defined")
-  ExInst<EigenbaseException> personalityManagesRowCount();
+  ExInst<CalciteException> personalityManagesRowCount();
 
   @BaseMessage("Personality does not support snapshot reads")
   @Property(name = "FeatureDefinition", value = "Eigenbase-defined")
-  ExInst<EigenbaseException> personalitySupportsSnapshots();
+  ExInst<CalciteException> personalitySupportsSnapshots();
 
   @BaseMessage("Personality does not support labels")
   @Property(name = "FeatureDefinition", value = "Eigenbase-defined")
-  ExInst<EigenbaseException> personalitySupportsLabels();
+  ExInst<CalciteException> personalitySupportsLabels();
 
   @BaseMessage("Require at least 1 argument")
   ExInst<SqlValidatorException> requireAtLeastOneArg();
@@ -534,10 +536,10 @@ public interface EigenbaseNewResource {
   ExInst<RuntimeException> firstParameterOfAdd(String className);
 
   @BaseMessage("FilterableTable.scan returned a filter that was not in the original list: {0}")
-  ExInst<EigenbaseException> filterableTableInventedFilter(String s);
+  ExInst<CalciteException> filterableTableInventedFilter(String s);
 
   @BaseMessage("FilterableTable.scan must not return null")
-  ExInst<EigenbaseException> filterableTableScanReturnedNull();
+  ExInst<CalciteException> filterableTableScanReturnedNull();
 }
 
-// End EigenbaseNewResource.java
+// End CalciteResource.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Enumerables.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Enumerables.java b/core/src/main/java/org/apache/calcite/runtime/Enumerables.java
index 92b14d6..c7e45f2 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Enumerables.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Enumerables.java
@@ -14,21 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.AbstractEnumerable;
-import net.hydromatic.linq4j.Enumerable;
-import net.hydromatic.linq4j.Enumerator;
-import net.hydromatic.linq4j.function.EqualityComparer;
-import net.hydromatic.linq4j.function.Function1;
-import net.hydromatic.linq4j.function.Predicate1;
-
-import net.hydromatic.optiq.impl.interpreter.Row;
-
-import org.eigenbase.util.Bug;
+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.function.EqualityComparer;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.function.Predicate1;
+import org.apache.calcite.util.Bug;
 
 /**
- * Utilities for processing {@link net.hydromatic.linq4j.Enumerable}
+ * Utilities for processing {@link org.apache.calcite.linq4j.Enumerable}
  * collections.
  *
  * <p>This class is a place to put things not yet added to linq4j.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/EnumeratorCursor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/EnumeratorCursor.java b/core/src/main/java/org/apache/calcite/runtime/EnumeratorCursor.java
index 4ce8d1c..ec6795b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/EnumeratorCursor.java
+++ b/core/src/main/java/org/apache/calcite/runtime/EnumeratorCursor.java
@@ -14,17 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Enumerator;
 
 /**
- * Implementation of {@link net.hydromatic.avatica.Cursor} on top of an
- * {@link net.hydromatic.linq4j.Enumerator} that
+ * Implementation of {@link org.apache.calcite.avatica.Cursor} on top of an
+ * {@link org.apache.calcite.linq4j.Enumerator} that
  * returns a record for each row. The returned record is cached to avoid
  * multiple computations of current row.
  * For instance,
- * {@link net.hydromatic.optiq.rules.java.JavaRules.EnumerableCalcRel}
+ * {@link org.apache.calcite.adapter.enumerable.EnumerableCalc}
  * computes result just in {@code current()} method, thus it makes sense to
  * cache the result and make it available for all the accessors.
  *

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Feature.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Feature.java b/core/src/main/java/org/apache/calcite/runtime/Feature.java
index 288491d..f38df94 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Feature.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Feature.java
@@ -14,17 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.resource;
+package org.apache.calcite.runtime;
 
 import java.lang.reflect.Method;
 import java.util.Locale;
 
-import org.eigenbase.util.EigenbaseContextException;
-
 /** SQL language feature. Expressed as the exception that would be thrown if it
  * were used while disabled. */
 public class Feature
-    extends Resources.ExInstWithCause<EigenbaseContextException> {
+    extends Resources.ExInstWithCause<CalciteContextException> {
   public Feature(String base, Locale locale, Method method, Object... args) {
     super(base, locale, method, args);
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
index 0956205..c2c887f 100644
--- a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
+++ b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
@@ -14,9 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import java.util.*;
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.RandomAccess;
 
 /**
  * Space-efficient, comparable, immutable lists.
@@ -573,4 +580,3 @@ public class FlatLists {
 }
 
 // End FlatLists.java
-

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Hook.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Hook.java b/core/src/main/java/org/apache/calcite/runtime/Hook.java
index f8abae4..2d10b31 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Hook.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Hook.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 import com.google.common.base.Function;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Like.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Like.java b/core/src/main/java/org/apache/calcite/runtime/Like.java
index a0b3c0e..91fa4d3 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Like.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Like.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 /**
  * Utilities for converting SQL {@code LIKE} and {@code SIMILAR} operators

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/ObjectEnumeratorCursor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/ObjectEnumeratorCursor.java b/core/src/main/java/org/apache/calcite/runtime/ObjectEnumeratorCursor.java
index 3f126ae..f73d7d6 100644
--- a/core/src/main/java/org/apache/calcite/runtime/ObjectEnumeratorCursor.java
+++ b/core/src/main/java/org/apache/calcite/runtime/ObjectEnumeratorCursor.java
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Enumerator;
 
 /**
- * Implementation of {@link net.hydromatic.avatica.Cursor} on top of an
- * {@link net.hydromatic.linq4j.Enumerator} that
+ * Implementation of {@link org.apache.calcite.avatica.Cursor} on top of an
+ * {@link org.apache.calcite.linq4j.Enumerator} that
  * returns an {@link Object} for each row.
  */
 public class ObjectEnumeratorCursor extends AbstractCursor {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/RecordEnumeratorCursor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/RecordEnumeratorCursor.java b/core/src/main/java/org/apache/calcite/runtime/RecordEnumeratorCursor.java
index 46ce62f..0e922bd 100644
--- a/core/src/main/java/org/apache/calcite/runtime/RecordEnumeratorCursor.java
+++ b/core/src/main/java/org/apache/calcite/runtime/RecordEnumeratorCursor.java
@@ -14,15 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Enumerator;
 
 import java.lang.reflect.Field;
 
 /**
- * Implementation of {@link net.hydromatic.avatica.Cursor} on top of an
- * {@link net.hydromatic.linq4j.Enumerator} that
+ * Implementation of {@link org.apache.calcite.avatica.Cursor} on top of an
+ * {@link org.apache.calcite.linq4j.Enumerator} that
  * returns a record for each row. The record is a synthetic class whose fields
  * are all public.
  *

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/ResultSetEnumerable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/ResultSetEnumerable.java b/core/src/main/java/org/apache/calcite/runtime/ResultSetEnumerable.java
index 3972004..b805a1c 100644
--- a/core/src/main/java/org/apache/calcite/runtime/ResultSetEnumerable.java
+++ b/core/src/main/java/org/apache/calcite/runtime/ResultSetEnumerable.java
@@ -14,16 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import net.hydromatic.linq4j.AbstractEnumerable;
-import net.hydromatic.linq4j.Enumerable;
-import net.hydromatic.linq4j.Enumerator;
-import net.hydromatic.linq4j.expressions.Primitive;
-import net.hydromatic.linq4j.function.Function0;
-import net.hydromatic.linq4j.function.Function1;
+import org.apache.calcite.linq4j.AbstractEnumerable;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.function.Function0;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.tree.Primitive;
 
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Statement;
+import java.sql.Types;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/SortedMultiMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/SortedMultiMap.java b/core/src/main/java/org/apache/calcite/runtime/SortedMultiMap.java
index 0aabb83..d4fa04e 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SortedMultiMap.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SortedMultiMap.java
@@ -14,9 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * Map that allows you to partition values into lists according to a common

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Spacer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Spacer.java b/core/src/main/java/org/apache/calcite/runtime/Spacer.java
index c5b145c..e028716 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Spacer.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Spacer.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 /**
  * Efficiently writes strings of spaces.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Spaces.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Spaces.java b/core/src/main/java/org/apache/calcite/runtime/Spaces.java
index c34e942..9921579 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Spaces.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Spaces.java
@@ -14,10 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
-
-import java.io.*;
-import java.util.*;
+package org.apache.calcite.runtime;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 /** Utilities for creating strings of spaces. */

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 9b4faac..a213ac3 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -14,26 +14,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
-
-import net.hydromatic.avatica.ByteString;
-
-import net.hydromatic.linq4j.Enumerable;
-import net.hydromatic.linq4j.Linq4j;
-import net.hydromatic.linq4j.expressions.Primitive;
-import net.hydromatic.linq4j.function.Deterministic;
-import net.hydromatic.linq4j.function.Function1;
-import net.hydromatic.linq4j.function.NonDeterministic;
-
-import net.hydromatic.optiq.DataContext;
-
-import org.eigenbase.util14.DateTimeUtil;
-
-import java.math.*;
+package org.apache.calcite.runtime;
+
+import org.apache.calcite.DataContext;
+import org.apache.calcite.avatica.ByteString;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.function.Deterministic;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.function.NonDeterministic;
+import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.util.DateTimeUtil;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.MathContext;
 import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.text.DecimalFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
 import java.util.regex.Pattern;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Typed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Typed.java b/core/src/main/java/org/apache/calcite/runtime/Typed.java
index 1e2fc78..8620981 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Typed.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Typed.java
@@ -14,12 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 import java.lang.reflect.Type;
 
 /**
- * Adds type information to a {@link net.hydromatic.linq4j.Enumerable}.
+ * Adds type information to a {@link org.apache.calcite.linq4j.Enumerable}.
  */
 public interface Typed {
   /**

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Unit.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Unit.java b/core/src/main/java/org/apache/calcite/runtime/Unit.java
index 08cee49..c3e29ca 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Unit.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Unit.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 /**
  * Synthetic record with zero fields.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/Utilities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Utilities.java b/core/src/main/java/org/apache/calcite/runtime/Utilities.java
index 73e7d4d..691afd5 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Utilities.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Utilities.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 import java.util.Iterator;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/runtime/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/package-info.java b/core/src/main/java/org/apache/calcite/runtime/package-info.java
index 14a6035..25e404f 100644
--- a/core/src/main/java/org/apache/calcite/runtime/package-info.java
+++ b/core/src/main/java/org/apache/calcite/runtime/package-info.java
@@ -18,6 +18,6 @@
 /**
  * Utilities required at runtime.
  */
-package net.hydromatic.optiq.runtime;
+package org.apache.calcite.runtime;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/AggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/AggregateFunction.java b/core/src/main/java/org/apache/calcite/schema/AggregateFunction.java
index 274ed73..30e6725 100644
--- a/core/src/main/java/org/apache/calcite/schema/AggregateFunction.java
+++ b/core/src/main/java/org/apache/calcite/schema/AggregateFunction.java
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import org.eigenbase.reltype.RelDataType;
-import org.eigenbase.reltype.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
 
 /**
  * Function that combines several values into a scalar result.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/FilterableTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/FilterableTable.java b/core/src/main/java/org/apache/calcite/schema/FilterableTable.java
index 7bc3a26..753fe91 100644
--- a/core/src/main/java/org/apache/calcite/schema/FilterableTable.java
+++ b/core/src/main/java/org/apache/calcite/schema/FilterableTable.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.linq4j.Enumerable;
-
-import org.eigenbase.rex.RexNode;
+import org.apache.calcite.DataContext;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.rex.RexNode;
 
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/Function.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/Function.java b/core/src/main/java/org/apache/calcite/schema/Function.java
index da4b3b2..cdca7a5 100644
--- a/core/src/main/java/org/apache/calcite/schema/Function.java
+++ b/core/src/main/java/org/apache/calcite/schema/Function.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/FunctionParameter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/FunctionParameter.java b/core/src/main/java/org/apache/calcite/schema/FunctionParameter.java
index fe25b5d..11e50c4 100644
--- a/core/src/main/java/org/apache/calcite/schema/FunctionParameter.java
+++ b/core/src/main/java/org/apache/calcite/schema/FunctionParameter.java
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import org.eigenbase.reltype.RelDataType;
-import org.eigenbase.reltype.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
 
 /**
  * Parameter to a {@link Function}.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/ImplementableAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/ImplementableAggFunction.java b/core/src/main/java/org/apache/calcite/schema/ImplementableAggFunction.java
index 277b1d1..94b0b45 100644
--- a/core/src/main/java/org/apache/calcite/schema/ImplementableAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/schema/ImplementableAggFunction.java
@@ -14,17 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.optiq.rules.java.AggImplementor;
+import org.apache.calcite.adapter.enumerable.AggImplementor;
 
 /**
  * Function that can be translated to java code.
  *
- * @see net.hydromatic.optiq.rules.java.AggImplementor
- * @see net.hydromatic.optiq.rules.java.WinAggImplementor
- * @see net.hydromatic.optiq.rules.java.StrictAggImplementor
- * @see net.hydromatic.optiq.rules.java.StrictWinAggImplementor
+ * @see org.apache.calcite.adapter.enumerable.AggImplementor
+ * @see org.apache.calcite.adapter.enumerable.WinAggImplementor
+ * @see org.apache.calcite.adapter.enumerable.StrictAggImplementor
+ * @see org.apache.calcite.adapter.enumerable.StrictWinAggImplementor
  */
 public interface ImplementableAggFunction extends AggregateFunction {
   /**

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java b/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java
index 2660efa..e138c3e 100644
--- a/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java
+++ b/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java
@@ -14,15 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.optiq.rules.java.CallImplementor;
+import org.apache.calcite.adapter.enumerable.CallImplementor;
 
 /**
  * Function that can be translated to java code.
- * <p>
- * @see net.hydromatic.optiq.ScalarFunction
- * @see net.hydromatic.optiq.TableFunction
+ *
+ * @see ScalarFunction
+ * @see TableFunction
  */
 public interface ImplementableFunction extends Function {
   /**

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/Member.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/Member.java b/core/src/main/java/org/apache/calcite/schema/Member.java
index 88984d3..e2eee27 100644
--- a/core/src/main/java/org/apache/calcite/schema/Member.java
+++ b/core/src/main/java/org/apache/calcite/schema/Member.java
@@ -14,11 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.linq4j.Queryable;
-
-import org.eigenbase.reltype.RelDataType;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.rel.type.RelDataType;
 
 import java.util.List;
 
@@ -69,10 +68,10 @@ public interface Member {
 
   /**
    * Evaluates this member to yield a result. The result is a
-   * {@link net.hydromatic.linq4j.Queryable}.
+   * {@link org.apache.calcite.linq4j.Queryable}.
    *
    * @param schemaInstance Object that is an instance of the containing
-   *                       {@link net.hydromatic.optiq.Schema}
+   *                       {@link Schema}
    * @param arguments List of arguments to the call; must match
    *                  {@link #getParameters() parameters} in number and type
    *

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/ModifiableTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/ModifiableTable.java b/core/src/main/java/org/apache/calcite/schema/ModifiableTable.java
index 527cbea..85b2a87 100644
--- a/core/src/main/java/org/apache/calcite/schema/ModifiableTable.java
+++ b/core/src/main/java/org/apache/calcite/schema/ModifiableTable.java
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.optiq.prepare.Prepare;
-
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.rel.TableModificationRelBase;
-import org.eigenbase.relopt.*;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.prepare.Prepare;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.TableModify;
 
 import java.util.Collection;
 import java.util.List;
@@ -37,12 +37,12 @@ public interface ModifiableTable extends QueryableTable {
   Collection getModifiableCollection();
 
   /** Creates a relational expression that modifies this table. */
-  TableModificationRelBase toModificationRel(
+  TableModify toModificationRel(
       RelOptCluster cluster,
       RelOptTable table,
       Prepare.CatalogReader catalogReader,
       RelNode child,
-      TableModificationRelBase.Operation operation,
+      TableModify.Operation operation,
       List<String> updateColumnList,
       boolean flattened);
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/ProjectableFilterableTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/ProjectableFilterableTable.java b/core/src/main/java/org/apache/calcite/schema/ProjectableFilterableTable.java
index e713b53..2f56865 100644
--- a/core/src/main/java/org/apache/calcite/schema/ProjectableFilterableTable.java
+++ b/core/src/main/java/org/apache/calcite/schema/ProjectableFilterableTable.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.linq4j.Enumerable;
-
-import org.eigenbase.rex.RexNode;
+import org.apache.calcite.DataContext;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.rex.RexNode;
 
 import java.util.List;
 
@@ -30,8 +30,8 @@ import java.util.List;
  * <p>If you wish to write a table that can apply projects but not filters,
  * simply decline all filters.</p>
  *
- * @see net.hydromatic.optiq.ScannableTable
- * @see net.hydromatic.optiq.FilterableTable
+ * @see ScannableTable
+ * @see FilterableTable
  */
 public interface ProjectableFilterableTable extends Table {
   /** Returns an enumerable over the rows in this Table.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/QueryableTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/QueryableTable.java b/core/src/main/java/org/apache/calcite/schema/QueryableTable.java
index a7c57ae..ab831cd 100644
--- a/core/src/main/java/org/apache/calcite/schema/QueryableTable.java
+++ b/core/src/main/java/org/apache/calcite/schema/QueryableTable.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import net.hydromatic.linq4j.QueryProvider;
-import net.hydromatic.linq4j.Queryable;
-import net.hydromatic.linq4j.expressions.Expression;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.linq4j.tree.Expression;
 
 import java.lang.reflect.Type;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/schema/ScalarFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/ScalarFunction.java b/core/src/main/java/org/apache/calcite/schema/ScalarFunction.java
index 9d8423d..13e7a7c 100644
--- a/core/src/main/java/org/apache/calcite/schema/ScalarFunction.java
+++ b/core/src/main/java/org/apache/calcite/schema/ScalarFunction.java
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite.schema;
 
-import org.eigenbase.reltype.RelDataType;
-import org.eigenbase.reltype.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
 
 /**
  * Function that returns a scalar result.