calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [35/58] [abbrv] [partial] incubator-calcite git commit: [CALCITE-306] Standardize code style for "import package.*; "
Date Fri, 14 Nov 2014 21:32:43 GMT
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java b/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
index 8e85e28..8cf2996 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
@@ -14,18 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.util.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.ReflectiveVisitor;
+import org.apache.calcite.util.Util;
 
 import com.google.common.base.Function;
-import com.google.common.collect.*;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
 
 /**
  * Implementation of the {@link RelMetadataProvider} interface that dispatches
@@ -74,17 +80,18 @@ public class ReflectiveRelMetadataProvider
    * methods with a preceding argument.
    *
    * <p>For example, {@link BuiltInMetadata.Selectivity} has a method
-   * {@link BuiltInMetadata.Selectivity#getSelectivity(org.eigenbase.rex.RexNode)}.
+   * {@link BuiltInMetadata.Selectivity#getSelectivity(org.apache.calcite.rex.RexNode)}.
    * A class</p>
    *
    * <blockquote><pre><code>
    * class RelMdSelectivity {
-   *   public Double getSelectivity(UnionRel rel, RexNode predicate) { ... }
-   *   public Double getSelectivity(FilterRel rel, RexNode predicate) { ... }
+   *   public Double getSelectivity(Union rel, RexNode predicate) { }
+   *   public Double getSelectivity(LogicalFilter rel, RexNode predicate) { }
    * </code></pre></blockquote>
    *
    * <p>provides implementations of selectivity for relational expressions
-   * that extend {@link UnionRel} or {@link FilterRel}.</p>
+   * that extend {@link org.apache.calcite.rel.logical.LogicalUnion}
+   * or {@link org.apache.calcite.rel.logical.LogicalFilter}.</p>
    */
   public static RelMetadataProvider reflectiveSource(Method method,
       final Object target) {
@@ -115,16 +122,17 @@ public class ReflectiveRelMetadataProvider
                         public Object invoke(Object proxy, Method method,
                             Object[] args) throws Throwable {
                           // Suppose we are an implementation of Selectivity
-                          // that wraps "filter", a FilterRel, Then we implement
+                          // that wraps "filter", a LogicalFilter. Then we
+                          // implement
                           //   Selectivity.selectivity(rex)
                           // by calling method
                           //   new SelectivityImpl().selectivity(filter, rex)
                           if (method.equals(
-                              BuiltinMethod.METADATA_REL.method)) {
+                              BuiltInMethod.METADATA_REL.method)) {
                             return rel;
                           }
                           if (method.equals(
-                              BuiltinMethod.OBJECT_TO_STRING.method)) {
+                              BuiltInMethod.OBJECT_TO_STRING.method)) {
                             return metadataClass0.getSimpleName() + "(" + rel
                                 + ")";
                           }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnMapping.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnMapping.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnMapping.java
index 44df143..4511f74 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnMapping.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnMapping.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
 /**
- * Mapping from an input column of a {@link org.eigenbase.rel.RelNode} to one
- * of its output columns.
+ * Mapping from an input column of a {@link org.apache.calcite.rel.RelNode} to
+ * one of its output columns.
  */
 public class RelColumnMapping {
   public RelColumnMapping(

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnOrigin.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnOrigin.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnOrigin.java
index 139d534..92cd7fe 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnOrigin.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelColumnOrigin.java
@@ -14,11 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
-
-import org.eigenbase.relopt.*;
+import org.apache.calcite.plan.RelOptTable;
 
 /**
  * RelColumnOrigin is a data structure describing one of the origins of an

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
index 72c11a6..d821744 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
@@ -14,24 +14,35 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SetOp;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.TableFunctionScan;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexVisitor;
+import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.util.BuiltInMethod;
 
-import org.eigenbase.rel.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.rex.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
- * RelMdColumnOrigins supplies a default implementation of {@link
- * RelMetadataQuery#getColumnOrigins} for the standard logical algebra.
+ * RelMdColumnOrigins supplies a default implementation of
+ * {@link RelMetadataQuery#getColumnOrigins} for the standard logical algebra.
  */
 public class RelMdColumnOrigins {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.COLUMN_ORIGIN.method, new RelMdColumnOrigins());
+          BuiltInMethod.COLUMN_ORIGIN.method, new RelMdColumnOrigins());
 
   //~ Constructors -----------------------------------------------------------
 
@@ -40,12 +51,12 @@ public class RelMdColumnOrigins {
   //~ Methods ----------------------------------------------------------------
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      AggregateRelBase rel,
+      Aggregate rel,
       int iOutputColumn) {
     if (iOutputColumn < rel.getGroupCount()) {
       // Group columns pass through directly.
       return invokeGetColumnOrigins(
-          rel.getChild(),
+          rel.getInput(),
           iOutputColumn);
     }
 
@@ -57,7 +68,7 @@ public class RelMdColumnOrigins {
     for (Integer iInput : call.getArgList()) {
       Set<RelColumnOrigin> inputSet =
           invokeGetColumnOrigins(
-              rel.getChild(), iInput);
+              rel.getInput(), iInput);
       inputSet = createDerivedColumnOrigins(inputSet);
       if (inputSet != null) {
         set.addAll(inputSet);
@@ -67,7 +78,7 @@ public class RelMdColumnOrigins {
   }
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      JoinRelBase rel,
+      Join rel,
       int iOutputColumn) {
     int nLeftColumns = rel.getLeft().getRowType().getFieldList().size();
     Set<RelColumnOrigin> set;
@@ -98,7 +109,7 @@ public class RelMdColumnOrigins {
   }
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      SetOpRel rel,
+      SetOp rel,
       int iOutputColumn) {
     Set<RelColumnOrigin> set = new HashSet<RelColumnOrigin>();
     for (RelNode input : rel.getInputs()) {
@@ -115,9 +126,9 @@ public class RelMdColumnOrigins {
   }
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      ProjectRelBase rel,
+      Project rel,
       int iOutputColumn) {
-    final RelNode child = rel.getChild();
+    final RelNode child = rel.getInput();
     RexNode rexNode = rel.getProjects().get(iOutputColumn);
 
     if (rexNode instanceof RexInputRef) {
@@ -150,23 +161,23 @@ public class RelMdColumnOrigins {
   }
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      FilterRelBase rel,
+      Filter rel,
       int iOutputColumn) {
     return invokeGetColumnOrigins(
-        rel.getChild(),
+        rel.getInput(),
         iOutputColumn);
   }
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      SortRel rel,
+      Sort rel,
       int iOutputColumn) {
     return invokeGetColumnOrigins(
-        rel.getChild(),
+        rel.getInput(),
         iOutputColumn);
   }
 
   public Set<RelColumnOrigin> getColumnOrigins(
-      TableFunctionRelBase rel,
+      TableFunctionScan rel,
       int iOutputColumn) {
     Set<RelColumnOrigin> set = new HashSet<RelColumnOrigin>();
     Set<RelColumnMapping> mappings = rel.getColumnMappings();

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
index e47addf..262d9e5 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
@@ -14,27 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Correlator;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinInfo;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.BuiltInMethod;
 
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.reltype.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.fun.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.util.BitSets;
+import java.util.BitSet;
+import java.util.List;
 
 /**
- * RelMdColumnUniqueness supplies a default implementation of {@link
- * RelMetadataQuery#areColumnsUnique} for the standard logical algebra.
+ * RelMdColumnUniqueness supplies a default implementation of
+ * {@link RelMetadataQuery#areColumnsUnique} for the standard logical algebra.
  */
 public class RelMdColumnUniqueness {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.COLUMN_UNIQUENESS.method, new RelMdColumnUniqueness());
+          BuiltInMethod.COLUMN_UNIQUENESS.method, new RelMdColumnUniqueness());
 
   //~ Constructors -----------------------------------------------------------
 
@@ -43,27 +53,27 @@ public class RelMdColumnUniqueness {
   //~ Methods ----------------------------------------------------------------
 
   public Boolean areColumnsUnique(
-      FilterRelBase rel,
+      Filter rel,
       BitSet columns,
       boolean ignoreNulls) {
     return RelMetadataQuery.areColumnsUnique(
-        rel.getChild(),
+        rel.getInput(),
         columns,
         ignoreNulls);
   }
 
   public Boolean areColumnsUnique(
-      SortRel rel,
+      Sort rel,
       BitSet columns,
       boolean ignoreNulls) {
     return RelMetadataQuery.areColumnsUnique(
-        rel.getChild(),
+        rel.getInput(),
         columns,
         ignoreNulls);
   }
 
   public Boolean areColumnsUnique(
-      CorrelatorRel rel,
+      Correlator rel,
       BitSet columns,
       boolean ignoreNulls) {
     return RelMetadataQuery.areColumnsUnique(
@@ -73,10 +83,10 @@ public class RelMdColumnUniqueness {
   }
 
   public Boolean areColumnsUnique(
-      ProjectRelBase rel,
+      Project rel,
       BitSet columns,
       boolean ignoreNulls) {
-    // ProjectRel maps a set of rows to a different set;
+    // LogicalProject maps a set of rows to a different set;
     // Without knowledge of the mapping function(whether it
     // preserves uniqueness), it is only safe to derive uniqueness
     // info from the child of a project when the mapping is f(a) => a.
@@ -128,13 +138,13 @@ public class RelMdColumnUniqueness {
     }
 
     return RelMetadataQuery.areColumnsUnique(
-        rel.getChild(),
+        rel.getInput(),
         childColumns,
         ignoreNulls);
   }
 
   public Boolean areColumnsUnique(
-      JoinRelBase rel,
+      Join rel,
       BitSet columns, boolean
       ignoreNulls) {
     if (columns.cardinality() == 0) {
@@ -208,7 +218,7 @@ public class RelMdColumnUniqueness {
   }
 
   public Boolean areColumnsUnique(
-      SemiJoinRel rel,
+      SemiJoin rel,
       BitSet columns,
       boolean ignoreNulls) {
     // only return the unique keys from the LHS since a semijoin only
@@ -220,7 +230,7 @@ public class RelMdColumnUniqueness {
   }
 
   public Boolean areColumnsUnique(
-      AggregateRelBase rel,
+      Aggregate rel,
       BitSet columns,
       boolean ignoreNulls) {
     // group by keys form a unique key

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
index b7637d8..e4d847d 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
@@ -14,28 +14,39 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.rel.core.Values;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.NumberUtil;
 
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.fun.*;
-import org.eigenbase.util14.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.util.BitSets;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.List;
 
 /**
- * RelMdDistinctRowCount supplies a default implementation of {@link
- * RelMetadataQuery#getDistinctRowCount} for the standard logical algebra.
+ * RelMdDistinctRowCount supplies a default implementation of
+ * {@link RelMetadataQuery#getDistinctRowCount} for the standard logical
+ * algebra.
  */
 public class RelMdDistinctRowCount {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.DISTINCT_ROW_COUNT.method, new RelMdDistinctRowCount());
+          BuiltInMethod.DISTINCT_ROW_COUNT.method, new RelMdDistinctRowCount());
 
   //~ Constructors -----------------------------------------------------------
 
@@ -44,7 +55,7 @@ public class RelMdDistinctRowCount {
   //~ Methods ----------------------------------------------------------------
 
   public Double getDistinctRowCount(
-      UnionRelBase rel,
+      Union rel,
       BitSet groupKey,
       RexNode predicate) {
     Double rowCount = 0.0;
@@ -78,17 +89,17 @@ public class RelMdDistinctRowCount {
   }
 
   public Double getDistinctRowCount(
-      SortRel rel,
+      Sort rel,
       BitSet groupKey,
       RexNode predicate) {
     return RelMetadataQuery.getDistinctRowCount(
-        rel.getChild(),
+        rel.getInput(),
         groupKey,
         predicate);
   }
 
   public Double getDistinctRowCount(
-      FilterRelBase rel,
+      Filter rel,
       BitSet groupKey,
       RexNode predicate) {
     // REVIEW zfong 4/18/06 - In the Broadbase code, duplicates are not
@@ -101,13 +112,13 @@ public class RelMdDistinctRowCount {
             rel.getCondition());
 
     return RelMetadataQuery.getDistinctRowCount(
-        rel.getChild(),
+        rel.getInput(),
         groupKey,
         unionPreds);
   }
 
   public Double getDistinctRowCount(
-      JoinRelBase rel,
+      Join rel,
       BitSet groupKey,
       RexNode predicate) {
     return RelMdUtil.getJoinDistinctRowCount(
@@ -119,7 +130,7 @@ public class RelMdDistinctRowCount {
   }
 
   public Double getDistinctRowCount(
-      SemiJoinRel rel,
+      SemiJoin rel,
       BitSet groupKey,
       RexNode predicate) {
     // create a RexNode representing the selectivity of the
@@ -141,7 +152,7 @@ public class RelMdDistinctRowCount {
   }
 
   public Double getDistinctRowCount(
-      AggregateRelBase rel,
+      Aggregate rel,
       BitSet groupKey,
       RexNode predicate) {
     // determine which predicates can be applied on the child of the
@@ -163,7 +174,7 @@ public class RelMdDistinctRowCount {
 
     Double distinctRowCount =
         RelMetadataQuery.getDistinctRowCount(
-            rel.getChild(),
+            rel.getInput(),
             childKey,
             childPreds);
     if (distinctRowCount == null) {
@@ -178,7 +189,7 @@ public class RelMdDistinctRowCount {
   }
 
   public Double getDistinctRowCount(
-      ValuesRelBase rel,
+      Values rel,
       BitSet groupKey,
       RexNode predicate) {
     Double selectivity = RelMdUtil.guessSelectivity(predicate);
@@ -189,7 +200,7 @@ public class RelMdDistinctRowCount {
   }
 
   public Double getDistinctRowCount(
-      ProjectRelBase rel,
+      Project rel,
       BitSet groupKey,
       RexNode predicate) {
     BitSet baseCols = new BitSet();
@@ -219,7 +230,7 @@ public class RelMdDistinctRowCount {
     }
     Double distinctRowCount =
         RelMetadataQuery.getDistinctRowCount(
-            rel.getChild(),
+            rel.getInput(),
             baseCols,
             modifiedPred);
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdExplainVisibility.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdExplainVisibility.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdExplainVisibility.java
index 68573b5..b0d926e 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdExplainVisibility.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdExplainVisibility.java
@@ -14,12 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import org.eigenbase.rel.*;
-import org.eigenbase.sql.SqlExplainLevel;
-
-import net.hydromatic.optiq.BuiltinMethod;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.sql.SqlExplainLevel;
+import org.apache.calcite.util.BuiltInMethod;
 
 /**
  * RelMdExplainVisibility supplies a default implementation of
@@ -28,7 +27,7 @@ import net.hydromatic.optiq.BuiltinMethod;
 public class RelMdExplainVisibility {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.EXPLAIN_VISIBILITY.method,
+          BuiltInMethod.EXPLAIN_VISIBILITY.method,
           new RelMdExplainVisibility());
 
   //~ Constructors -----------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPercentageOriginalRows.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPercentageOriginalRows.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPercentageOriginalRows.java
index 7b4a677..991a488 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPercentageOriginalRows.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPercentageOriginalRows.java
@@ -14,18 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.relopt.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.rules.java.JavaRules;
+import org.apache.calcite.adapter.enumerable.EnumerableInterpreter;
+import org.apache.calcite.plan.RelOptCost;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.util.BuiltInMethod;
 
 import com.google.common.collect.ImmutableList;
 
+import java.util.List;
+
 /**
  * RelMdPercentageOriginalRows supplies a default implementation of
  * {@link RelMetadataQuery#getPercentageOriginalRows} for the standard logical
@@ -39,28 +41,28 @@ public class RelMdPercentageOriginalRows {
       ChainedRelMetadataProvider.of(
           ImmutableList.of(
               ReflectiveRelMetadataProvider.reflectiveSource(
-                  BuiltinMethod.PERCENTAGE_ORIGINAL_ROWS.method, INSTANCE),
+                  BuiltInMethod.PERCENTAGE_ORIGINAL_ROWS.method, INSTANCE),
 
               ReflectiveRelMetadataProvider.reflectiveSource(
-                  BuiltinMethod.CUMULATIVE_COST.method, INSTANCE),
+                  BuiltInMethod.CUMULATIVE_COST.method, INSTANCE),
 
               ReflectiveRelMetadataProvider.reflectiveSource(
-                  BuiltinMethod.NON_CUMULATIVE_COST.method, INSTANCE)));
+                  BuiltInMethod.NON_CUMULATIVE_COST.method, INSTANCE)));
 
   //~ Methods ----------------------------------------------------------------
 
   private RelMdPercentageOriginalRows() {}
 
-  public Double getPercentageOriginalRows(AggregateRelBase rel) {
+  public Double getPercentageOriginalRows(Aggregate rel) {
     // REVIEW jvs 28-Mar-2006: The assumption here seems to be that
     // aggregation does not apply any filtering, so it does not modify the
     // percentage.  That's very much oversimplified.
 
     return RelMetadataQuery.getPercentageOriginalRows(
-        rel.getChild());
+        rel.getInput());
   }
 
-  public Double getPercentageOriginalRows(UnionRelBase rel) {
+  public Double getPercentageOriginalRows(Union rel) {
     double numerator = 0.0;
     double denominator = 0.0;
 
@@ -87,14 +89,14 @@ public class RelMdPercentageOriginalRows {
     return quotientForPercentage(numerator, denominator);
   }
 
-  public Double getPercentageOriginalRows(JoinRelBase rel) {
+  public Double getPercentageOriginalRows(Join rel) {
     // Assume any single-table filter conditions have already
     // been pushed down.
 
     // REVIEW jvs 28-Mar-2006: As with aggregation, this is
     // oversimplified.
 
-    // REVIEW jvs 28-Mar-2006:  need any special casing for SemiJoinRel?
+    // REVIEW jvs 28-Mar-2006:  need any special casing for SemiJoin?
 
     double left = RelMetadataQuery.getPercentageOriginalRows(rel.getLeft());
 
@@ -154,7 +156,7 @@ public class RelMdPercentageOriginalRows {
     return cost;
   }
 
-  public RelOptCost getCumulativeCost(JavaRules.EnumerableInterpreterRel rel) {
+  public RelOptCost getCumulativeCost(EnumerableInterpreter rel) {
     return RelMetadataQuery.getNonCumulativeCost(rel);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
index 1755589..2afbc80 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPopulationSize.java
@@ -14,25 +14,32 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
-
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.rex.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.util.BitSets;
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.rel.core.Values;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.BuiltInMethod;
+
+import java.util.BitSet;
+import java.util.List;
 
 /**
- * RelMdPopulationSize supplies a default implementation of {@link
- * RelMetadataQuery#getPopulationSize} for the standard logical algebra.
+ * RelMdPopulationSize supplies a default implementation of
+ * {@link RelMetadataQuery#getPopulationSize} for the standard logical algebra.
  */
 public class RelMdPopulationSize {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.POPULATION_SIZE.method, new RelMdPopulationSize());
+          BuiltInMethod.POPULATION_SIZE.method, new RelMdPopulationSize());
 
   //~ Constructors -----------------------------------------------------------
 
@@ -40,19 +47,19 @@ public class RelMdPopulationSize {
 
   //~ Methods ----------------------------------------------------------------
 
-  public Double getPopulationSize(FilterRelBase rel, BitSet groupKey) {
+  public Double getPopulationSize(Filter rel, BitSet groupKey) {
     return RelMetadataQuery.getPopulationSize(
-        rel.getChild(),
+        rel.getInput(),
         groupKey);
   }
 
-  public Double getPopulationSize(SortRel rel, BitSet groupKey) {
+  public Double getPopulationSize(Sort rel, BitSet groupKey) {
     return RelMetadataQuery.getPopulationSize(
-        rel.getChild(),
+        rel.getInput(),
         groupKey);
   }
 
-  public Double getPopulationSize(UnionRelBase rel, BitSet groupKey) {
+  public Double getPopulationSize(Union rel, BitSet groupKey) {
     Double population = 0.0;
     for (RelNode input : rel.getInputs()) {
       Double subPop = RelMetadataQuery.getPopulationSize(input, groupKey);
@@ -64,30 +71,30 @@ public class RelMdPopulationSize {
     return population;
   }
 
-  public Double getPopulationSize(JoinRelBase rel, BitSet groupKey) {
+  public Double getPopulationSize(Join rel, BitSet groupKey) {
     return RelMdUtil.getJoinPopulationSize(rel, groupKey);
   }
 
-  public Double getPopulationSize(SemiJoinRel rel, BitSet groupKey) {
+  public Double getPopulationSize(SemiJoin rel, BitSet groupKey) {
     return RelMetadataQuery.getPopulationSize(
         rel.getLeft(),
         groupKey);
   }
 
-  public Double getPopulationSize(AggregateRelBase rel, BitSet groupKey) {
+  public Double getPopulationSize(Aggregate rel, BitSet groupKey) {
     BitSet childKey = new BitSet();
     RelMdUtil.setAggChildKeys(groupKey, rel, childKey);
     return RelMetadataQuery.getPopulationSize(
-        rel.getChild(),
+        rel.getInput(),
         childKey);
   }
 
-  public Double getPopulationSize(ValuesRelBase rel, BitSet groupKey) {
+  public Double getPopulationSize(Values rel, BitSet groupKey) {
     // assume half the rows are duplicates
     return rel.getRows() / 2;
   }
 
-  public Double getPopulationSize(ProjectRelBase rel, BitSet groupKey) {
+  public Double getPopulationSize(Project rel, BitSet groupKey) {
     BitSet baseCols = new BitSet();
     BitSet projCols = new BitSet();
     List<RexNode> projExprs = rel.getProjects();
@@ -95,7 +102,7 @@ public class RelMdPopulationSize {
 
     Double population =
         RelMetadataQuery.getPopulationSize(
-            rel.getChild(),
+            rel.getInput(),
             baseCols);
     if (population == null) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
index eec7dd8..e15f074 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
@@ -14,7 +14,42 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.Ord;
+import org.apache.calcite.linq4j.function.Predicate1;
+import org.apache.calcite.plan.RelOptPredicateList;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.TableScan;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexPermuteInputsShuttle;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.mapping.Mapping;
+import org.apache.calcite.util.mapping.MappingType;
+import org.apache.calcite.util.mapping.Mappings;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
 import java.util.BitSet;
@@ -27,48 +62,11 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import org.eigenbase.rel.AggregateRelBase;
-import org.eigenbase.rel.FilterRelBase;
-import org.eigenbase.rel.JoinRelBase;
-import org.eigenbase.rel.JoinRelType;
-import org.eigenbase.rel.ProjectRelBase;
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.rel.SortRel;
-import org.eigenbase.rel.TableAccessRelBase;
-import org.eigenbase.rel.UnionRelBase;
-import org.eigenbase.rel.rules.SemiJoinRel;
-import org.eigenbase.relopt.RelOptPredicateList;
-import org.eigenbase.relopt.RelOptUtil;
-import org.eigenbase.rex.RexBuilder;
-import org.eigenbase.rex.RexCall;
-import org.eigenbase.rex.RexInputRef;
-import org.eigenbase.rex.RexNode;
-import org.eigenbase.rex.RexPermuteInputsShuttle;
-import org.eigenbase.rex.RexUtil;
-import org.eigenbase.rex.RexVisitorImpl;
-import org.eigenbase.sql.SqlKind;
-import org.eigenbase.util.mapping.Mapping;
-import org.eigenbase.util.mapping.MappingType;
-import org.eigenbase.util.mapping.Mappings;
-
-import net.hydromatic.linq4j.Linq4j;
-import net.hydromatic.linq4j.Ord;
-import net.hydromatic.linq4j.function.Predicate1;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.util.BitSets;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-
 /**
  * Utility to infer Predicates that are applicable above a RelNode.
  *
  * <p>This is currently used by
- * {@link org.eigenbase.rel.rules.TransitivePredicatesOnJoinRule} to
+ * {@link org.apache.calcite.rel.rules.JoinPushTransitivePredicatesRule} to
  * infer <em>Predicates</em> that can be inferred from one side of a Join
  * to the other.
  *
@@ -111,7 +109,7 @@ import com.google.common.collect.Lists;
  */
 public class RelMdPredicates {
   public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider
-      .reflectiveSource(BuiltinMethod.PREDICATES.method, new RelMdPredicates());
+      .reflectiveSource(BuiltInMethod.PREDICATES.method, new RelMdPredicates());
 
   private static final List<RexNode> EMPTY_LIST = ImmutableList.of();
 
@@ -123,7 +121,7 @@ public class RelMdPredicates {
   /**
    * Infers predicates for a table scan.
    */
-  public RelOptPredicateList getPredicates(TableAccessRelBase table) {
+  public RelOptPredicateList getPredicates(TableScan table) {
     return RelOptPredicateList.EMPTY;
   }
 
@@ -146,8 +144,8 @@ public class RelMdPredicates {
    *
    * </ol>
    */
-  public RelOptPredicateList getPredicates(ProjectRelBase project) {
-    RelNode child = project.getChild();
+  public RelOptPredicateList getPredicates(Project project) {
+    RelNode child = project.getInput();
     RelOptPredicateList childInfo =
         RelMetadataQuery.getPulledUpPredicates(child);
 
@@ -181,8 +179,8 @@ public class RelMdPredicates {
   /**
    * Add the Filter condition to the pulledPredicates list from the child.
    */
-  public RelOptPredicateList getPredicates(FilterRelBase filter) {
-    RelNode child = filter.getChild();
+  public RelOptPredicateList getPredicates(Filter filter) {
+    RelNode child = filter.getInput();
     RelOptPredicateList childInfo =
         RelMetadataQuery.getPulledUpPredicates(child);
 
@@ -191,15 +189,15 @@ public class RelMdPredicates {
             RelOptUtil.conjunctions(filter.getCondition())));
   }
 
-  /** Infers predicates for a {@link SemiJoinRel}. */
-  public RelOptPredicateList getPredicates(SemiJoinRel semiJoin) {
+  /** Infers predicates for a {@link org.apache.calcite.rel.core.SemiJoin}. */
+  public RelOptPredicateList getPredicates(SemiJoin semiJoin) {
     // Workaround, pending [CALCITE-390] "Transitive inference (RelMdPredicate)
     // doesn't handle semi-join"
     return RelOptPredicateList.EMPTY;
   }
 
-  /** Infers predicates for a {@link JoinRelBase}. */
-  public RelOptPredicateList getPredicates(JoinRelBase join) {
+  /** Infers predicates for a {@link org.apache.calcite.rel.core.Join}. */
+  public RelOptPredicateList getPredicates(Join join) {
     RexBuilder rB = join.getCluster().getRexBuilder();
     RelNode left = join.getInput(0);
     RelNode right = join.getInput(1);
@@ -219,7 +217,7 @@ public class RelMdPredicates {
   }
 
   /**
-   * Infers predicates for an AggregateRel.
+   * Infers predicates for an Aggregate.
    *
    * <p>Pulls up predicates that only contains references to columns in the
    * GroupSet. For e.g.
@@ -230,8 +228,8 @@ public class RelMdPredicates {
    * pulledUpExprs    : { a &gt; 7}
    * </pre>
    */
-  public RelOptPredicateList getPredicates(AggregateRelBase agg) {
-    RelNode child = agg.getChild();
+  public RelOptPredicateList getPredicates(Aggregate agg) {
+    RelNode child = agg.getInput();
     RelOptPredicateList childInfo =
         RelMetadataQuery.getPulledUpPredicates(child);
 
@@ -257,11 +255,11 @@ public class RelMdPredicates {
   }
 
   /**
-   * Infers predicates for a UnionRelBase.
+   * Infers predicates for a Union.
    *
    * <p>The pulled up expression is a disjunction of its children's predicates.
    */
-  public RelOptPredicateList getPredicates(UnionRelBase union) {
+  public RelOptPredicateList getPredicates(Union union) {
     RexBuilder rB = union.getCluster().getRexBuilder();
     List<RexNode> orList = Lists.newArrayList();
     for (RelNode input : union.getInputs()) {
@@ -282,20 +280,28 @@ public class RelMdPredicates {
   }
 
   /**
-   * Infers predicates for a SortRel.
+   * Infers predicates for a Sort.
    */
-  public RelOptPredicateList getPredicates(SortRel sort) {
+  public RelOptPredicateList getPredicates(Sort sort) {
     RelNode child = sort.getInput(0);
     return RelMetadataQuery.getPulledUpPredicates(child);
   }
 
   /**
    * Utility to infer predicates from one side of the join that apply on the
-   * other side. Contract is: - initialize with a {@link JoinRelBase} and
-   * optional predicates applicable on its left and right subtrees. - you can
+   * other side.
+   *
+   * <p>Contract is:<ul>
+   *
+   * <li>initialize with a {@link org.apache.calcite.rel.core.Join} and
+   * optional predicates applicable on its left and right subtrees.
+   *
+   * <li>you can
    * then ask it for equivalentPredicate(s) given a predicate.
-   * <p>
-   * So for:
+   *
+   * </ul>
+   *
+   * <p>So for:
    * <ol>
    * <li>'<code>R1(x) join R2(y) on x = y</code>' a call for
    * equivalentPredicates on '<code>x > 7</code>' will return '
@@ -306,7 +312,7 @@ public class RelMdPredicates {
    * </ol>
    */
   static class JoinConditionBasedPredicateInference {
-    final JoinRelBase joinRel;
+    final Join joinRel;
     final int nSysFields;
     final int nFieldsLeft;
     final int nFieldsRight;
@@ -320,7 +326,7 @@ public class RelMdPredicates {
     final RexNode leftChildPredicates;
     final RexNode rightChildPredicates;
 
-    public JoinConditionBasedPredicateInference(JoinRelBase joinRel,
+    public JoinConditionBasedPredicateInference(Join joinRel,
         RexNode lPreds, RexNode rPreds) {
       super();
       this.joinRel = joinRel;
@@ -535,8 +541,7 @@ public class RelMdPredicates {
         super(true);
       }
 
-      @Override
-      public Void visitCall(RexCall call) {
+      @Override public Void visitCall(RexCall call) {
         if (call.getOperator().getKind() == SqlKind.EQUALS) {
           int lPos = pos(call.getOperands().get(0));
           int rPos = pos(call.getOperands().get(1));

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
index 01df90e..2549570 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
@@ -14,29 +14,33 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.NumberUtil;
 
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.util14.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
+import java.util.BitSet;
 
 /**
- * RelMdRowCount supplies a default implementation of {@link
- * RelMetadataQuery#getRowCount} for the standard logical algebra.
+ * RelMdRowCount supplies a default implementation of
+ * {@link RelMetadataQuery#getRowCount} for the standard logical algebra.
  */
 public class RelMdRowCount {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.ROW_COUNT.method, new RelMdRowCount());
+          BuiltInMethod.ROW_COUNT.method, new RelMdRowCount());
 
   //~ Methods ----------------------------------------------------------------
 
-  public Double getRowCount(UnionRelBase rel) {
+  public Double getRowCount(Union rel) {
     double nRows = 0.0;
 
     for (RelNode input : rel.getInputs()) {
@@ -49,23 +53,23 @@ public class RelMdRowCount {
     return nRows;
   }
 
-  public Double getRowCount(FilterRelBase rel) {
+  public Double getRowCount(Filter rel) {
     return NumberUtil.multiply(
         RelMetadataQuery.getSelectivity(
-            rel.getChild(),
+            rel.getInput(),
             rel.getCondition()),
-        RelMetadataQuery.getRowCount(rel.getChild()));
+        RelMetadataQuery.getRowCount(rel.getInput()));
   }
 
-  public Double getRowCount(ProjectRelBase rel) {
-    return RelMetadataQuery.getRowCount(rel.getChild());
+  public Double getRowCount(Project rel) {
+    return RelMetadataQuery.getRowCount(rel.getInput());
   }
 
-  public Double getRowCount(SortRel rel) {
-    return RelMetadataQuery.getRowCount(rel.getChild());
+  public Double getRowCount(Sort rel) {
+    return RelMetadataQuery.getRowCount(rel.getInput());
   }
 
-  public Double getRowCount(SemiJoinRel rel) {
+  public Double getRowCount(SemiJoin rel) {
     // create a RexNode representing the selectivity of the
     // semijoin filter and pass it to getSelectivity
     RexNode semiJoinSelectivity =
@@ -78,7 +82,7 @@ public class RelMdRowCount {
         RelMetadataQuery.getRowCount(rel.getLeft()));
   }
 
-  public Double getRowCount(AggregateRelBase rel) {
+  public Double getRowCount(Aggregate rel) {
     BitSet groupKey = new BitSet();
     for (int i = 0; i < rel.getGroupCount(); i++) {
       groupKey.set(i);
@@ -87,11 +91,11 @@ public class RelMdRowCount {
     // rowcount is the cardinality of the group by columns
     Double distinctRowCount =
         RelMetadataQuery.getDistinctRowCount(
-            rel.getChild(),
+            rel.getInput(),
             groupKey,
             null);
     if (distinctRowCount == null) {
-      return RelMetadataQuery.getRowCount(rel.getChild()) / 10;
+      return RelMetadataQuery.getRowCount(rel.getInput()) / 10;
     } else {
       return distinctRowCount;
     }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSelectivity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSelectivity.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSelectivity.java
index 9cfbf1b..1706e13 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSelectivity.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdSelectivity.java
@@ -14,27 +14,34 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
-
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.fun.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.util.BitSets;
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.BuiltInMethod;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
- * RelMdSelectivity supplies a default implementation of {@link
- * RelMetadataQuery#getSelectivity} for the standard logical algebra.
+ * RelMdSelectivity supplies a default implementation of
+ * {@link RelMetadataQuery#getSelectivity} for the standard logical algebra.
  */
 public class RelMdSelectivity {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.SELECTIVITY.method, new RelMdSelectivity());
+          BuiltInMethod.SELECTIVITY.method, new RelMdSelectivity());
 
   //~ Constructors -----------------------------------------------------------
 
@@ -43,7 +50,7 @@ public class RelMdSelectivity {
 
   //~ Methods ----------------------------------------------------------------
 
-  public Double getSelectivity(UnionRelBase rel, RexNode predicate) {
+  public Double getSelectivity(Union rel, RexNode predicate) {
     if ((rel.getInputs().size() == 0) || (predicate == null)) {
       return 1.0;
     }
@@ -78,32 +85,32 @@ public class RelMdSelectivity {
     return sumSelectedRows / sumRows;
   }
 
-  public Double getSelectivity(SortRel rel, RexNode predicate) {
+  public Double getSelectivity(Sort rel, RexNode predicate) {
     return RelMetadataQuery.getSelectivity(
-        rel.getChild(),
+        rel.getInput(),
         predicate);
   }
 
-  public Double getSelectivity(FilterRelBase rel, RexNode predicate) {
+  public Double getSelectivity(Filter rel, RexNode predicate) {
     // Take the difference between the predicate passed in and the
     // predicate in the filter's condition, so we don't apply the
     // selectivity of the filter twice.  If no predicate is passed in,
     // use the filter's condition.
     if (predicate != null) {
       return RelMetadataQuery.getSelectivity(
-          rel.getChild(),
+          rel.getInput(),
           RelMdUtil.minusPreds(
               rel.getCluster().getRexBuilder(),
               predicate,
               rel.getCondition()));
     } else {
       return RelMetadataQuery.getSelectivity(
-          rel.getChild(),
+          rel.getInput(),
           rel.getCondition());
     }
   }
 
-  public Double getSelectivity(SemiJoinRel rel, RexNode predicate) {
+  public Double getSelectivity(SemiJoin rel, RexNode predicate) {
     // create a RexNode representing the selectivity of the
     // semijoin filter and pass it to getSelectivity
     RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
@@ -121,7 +128,7 @@ public class RelMdSelectivity {
         newPred);
   }
 
-  public Double getSelectivity(AggregateRelBase rel, RexNode predicate) {
+  public Double getSelectivity(Aggregate rel, RexNode predicate) {
     List<RexNode> notPushable = new ArrayList<RexNode>();
     List<RexNode> pushable = new ArrayList<RexNode>();
     RelOptUtil.splitFilters(
@@ -135,7 +142,7 @@ public class RelMdSelectivity {
 
     Double selectivity =
         RelMetadataQuery.getSelectivity(
-            rel.getChild(),
+            rel.getInput(),
             childPred);
     if (selectivity == null) {
       return null;
@@ -146,7 +153,7 @@ public class RelMdSelectivity {
     }
   }
 
-  public Double getSelectivity(ProjectRelBase rel, RexNode predicate) {
+  public Double getSelectivity(Project rel, RexNode predicate) {
     List<RexNode> notPushable = new ArrayList<RexNode>();
     List<RexNode> pushable = new ArrayList<RexNode>();
     RelOptUtil.splitFilters(
@@ -166,7 +173,7 @@ public class RelMdSelectivity {
     }
     Double selectivity =
         RelMetadataQuery.getSelectivity(
-            rel.getChild(),
+            rel.getInput(),
             modifiedPred);
     if (selectivity == null) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
index cdebe60..55083d8 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
@@ -14,25 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
-
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.rex.*;
-
-import net.hydromatic.optiq.BuiltinMethod;
-import net.hydromatic.optiq.util.BitSets;
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.Correlator;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinInfo;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.SemiJoin;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.BuiltInMethod;
+
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
- * RelMdUniqueKeys supplies a default implementation of {@link
- * RelMetadataQuery#getUniqueKeys} for the standard logical algebra.
+ * RelMdUniqueKeys supplies a default implementation of
+ * {@link RelMetadataQuery#getUniqueKeys} for the standard logical algebra.
  */
 public class RelMdUniqueKeys {
   public static final RelMetadataProvider SOURCE =
       ReflectiveRelMetadataProvider.reflectiveSource(
-          BuiltinMethod.UNIQUE_KEYS.method, new RelMdUniqueKeys());
+          BuiltInMethod.UNIQUE_KEYS.method, new RelMdUniqueKeys());
 
   //~ Constructors -----------------------------------------------------------
 
@@ -40,20 +52,20 @@ public class RelMdUniqueKeys {
 
   //~ Methods ----------------------------------------------------------------
 
-  public Set<BitSet> getUniqueKeys(FilterRelBase rel, boolean ignoreNulls) {
-    return RelMetadataQuery.getUniqueKeys(rel.getChild(), ignoreNulls);
+  public Set<BitSet> getUniqueKeys(Filter rel, boolean ignoreNulls) {
+    return RelMetadataQuery.getUniqueKeys(rel.getInput(), ignoreNulls);
   }
 
-  public Set<BitSet> getUniqueKeys(SortRel rel, boolean ignoreNulls) {
-    return RelMetadataQuery.getUniqueKeys(rel.getChild(), ignoreNulls);
+  public Set<BitSet> getUniqueKeys(Sort rel, boolean ignoreNulls) {
+    return RelMetadataQuery.getUniqueKeys(rel.getInput(), ignoreNulls);
   }
 
-  public Set<BitSet> getUniqueKeys(CorrelatorRel rel, boolean ignoreNulls) {
+  public Set<BitSet> getUniqueKeys(Correlator rel, boolean ignoreNulls) {
     return RelMetadataQuery.getUniqueKeys(rel.getLeft(), ignoreNulls);
   }
 
-  public Set<BitSet> getUniqueKeys(ProjectRelBase rel, boolean ignoreNulls) {
-    // ProjectRel maps a set of rows to a different set;
+  public Set<BitSet> getUniqueKeys(Project rel, boolean ignoreNulls) {
+    // LogicalProject maps a set of rows to a different set;
     // Without knowledge of the mapping function(whether it
     // preserves uniqueness), it is only safe to derive uniqueness
     // info from the child of a project when the mapping is f(a) => a.
@@ -81,7 +93,7 @@ public class RelMdUniqueKeys {
     }
 
     Set<BitSet> childUniqueKeySet =
-        RelMetadataQuery.getUniqueKeys(rel.getChild(), ignoreNulls);
+        RelMetadataQuery.getUniqueKeys(rel.getInput(), ignoreNulls);
 
     if (childUniqueKeySet != null) {
       // Now add to the projUniqueKeySet the child keys that are fully
@@ -108,7 +120,7 @@ public class RelMdUniqueKeys {
     return projUniqueKeySet;
   }
 
-  public Set<BitSet> getUniqueKeys(JoinRelBase rel, boolean ignoreNulls) {
+  public Set<BitSet> getUniqueKeys(Join rel, boolean ignoreNulls) {
     final RelNode left = rel.getLeft();
     final RelNode right = rel.getRight();
 
@@ -184,13 +196,13 @@ public class RelMdUniqueKeys {
     return retSet;
   }
 
-  public Set<BitSet> getUniqueKeys(SemiJoinRel rel, boolean ignoreNulls) {
+  public Set<BitSet> getUniqueKeys(SemiJoin rel, boolean ignoreNulls) {
     // only return the unique keys from the LHS since a semijoin only
     // returns the LHS
     return RelMetadataQuery.getUniqueKeys(rel.getLeft(), ignoreNulls);
   }
 
-  public Set<BitSet> getUniqueKeys(AggregateRelBase rel, boolean ignoreNulls) {
+  public Set<BitSet> getUniqueKeys(Aggregate rel, boolean ignoreNulls) {
     Set<BitSet> retSet = new HashSet<BitSet>();
 
     // group by keys form a unique key

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
index 043c293..e3128fb 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdUtil.java
@@ -14,24 +14,41 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
-
-import java.math.*;
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.rules.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.*;
-import org.eigenbase.sql.type.*;
-import org.eigenbase.util.Bug;
-import org.eigenbase.util14.*;
-
-import net.hydromatic.optiq.util.BitSets;
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.AggregateCall;
+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.SemiJoin;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.Bug;
+import org.apache.calcite.util.NumberUtil;
 
 import com.google.common.collect.ImmutableList;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 /**
  * RelMdUtil provides utility methods used by the metadata provider methods.
  */
@@ -60,7 +77,7 @@ public class RelMdUtil {
    * @param rel the semijoin of interest
    * @return constructed rexnode
    */
-  public static RexNode makeSemiJoinSelectivityRexNode(SemiJoinRel rel) {
+  public static RexNode makeSemiJoinSelectivityRexNode(SemiJoin rel) {
     RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
     double selectivity =
         computeSemiJoinSelectivity(
@@ -96,7 +113,7 @@ public class RelMdUtil {
    * @param rel semijoin rel
    * @return calculated selectivity
    */
-  public static double computeSemiJoinSelectivity(SemiJoinRel rel) {
+  public static double computeSemiJoinSelectivity(SemiJoin rel) {
     return computeSemiJoinSelectivity(
         rel.getLeft(),
         rel.getRight(),
@@ -118,7 +135,7 @@ public class RelMdUtil {
   public static double computeSemiJoinSelectivity(
       RelNode factRel,
       RelNode dimRel,
-      SemiJoinRel rel) {
+      SemiJoin rel) {
     return computeSemiJoinSelectivity(
         factRel,
         dimRel,
@@ -518,7 +535,7 @@ public class RelMdUtil {
    */
   public static void setAggChildKeys(
       BitSet groupKey,
-      AggregateRelBase aggRel,
+      Aggregate aggRel,
       BitSet childKey) {
     List<AggregateCall> aggCalls = aggRel.getAggCallList();
     for (int bit : BitSets.toIter(groupKey)) {
@@ -568,7 +585,7 @@ public class RelMdUtil {
    * @param expr projection expression
    * @return cardinality
    */
-  public static Double cardOfProjExpr(ProjectRelBase rel, RexNode expr) {
+  public static Double cardOfProjExpr(Project rel, RexNode expr) {
     return expr.accept(new CardOfProjExpr(rel));
   }
 
@@ -697,9 +714,9 @@ public class RelMdUtil {
   /** Visitor that walks over a scalar expression and computes the
    * cardinality of its result. */
   private static class CardOfProjExpr extends RexVisitorImpl<Double> {
-    private ProjectRelBase rel;
+    private Project rel;
 
-    public CardOfProjExpr(ProjectRelBase rel) {
+    public CardOfProjExpr(Project rel) {
       super(true);
       this.rel = rel;
     }
@@ -710,7 +727,7 @@ public class RelMdUtil {
       col.set(index);
       Double distinctRowCount =
           RelMetadataQuery.getDistinctRowCount(
-              rel.getChild(),
+              rel.getInput(),
               col,
               null);
       if (distinctRowCount == null) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataProvider.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataProvider.java
index fd363da..0e1bf4f 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataProvider.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataProvider.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import org.eigenbase.rel.*;
+import org.apache.calcite.rel.RelNode;
 
 import com.google.common.base.Function;
 
@@ -43,10 +43,10 @@ public interface RelMetadataProvider {
    *
    * <blockquote><pre>
    * RelMetadataProvider provider;
-   * FilterRel filter;
+   * LogicalFilter filter;
    * RexNode predicate;
    * Function&lt;RelNode, Metadata&gt; function =
-   *   provider.apply(FilterRel.class, Selectivity.class};
+   *   provider.apply(LogicalFilter.class, Selectivity.class};
    * Selectivity selectivity = function.apply(filter);
    * Double d = selectivity.selectivity(predicate);
    * </pre></blockquote>

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
index ed5ed48..4d86f79 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
@@ -14,30 +14,32 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.*;
-import org.eigenbase.stat.*;
+import org.apache.calcite.plan.RelOptCost;
+import org.apache.calcite.plan.RelOptPredicateList;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.SqlExplainLevel;
 
 import com.google.common.collect.Iterables;
 
+import java.util.BitSet;
+import java.util.Set;
+
 /**
- * RelMetadataQuery provides a strongly-typed facade on top of {@link
- * RelMetadataProvider} for the set of relational expression metadata queries
- * defined as standard within Eigenbase. The Javadoc on these methods serves as
- * their primary specification.
+ * RelMetadataQuery provides a strongly-typed facade on top of
+ * {@link RelMetadataProvider} for the set of relational expression metadata
+ * queries defined as standard within Calcite. The Javadoc on these methods
+ * serves as their primary specification.
  *
  * <p>To add a new standard query <code>Xyz</code> to this interface, follow
  * these steps:
  *
  * <ol>
  * <li>Add a static method <code>getXyz</code> specification to this class.
- * <li>Add unit tests to {@code org.eigenbase.test.RelMetadataTest}.
+ * <li>Add unit tests to {@code org.apache.calcite.test.RelMetadataTest}.
  * <li>Write a new provider class <code>RelMdXyz</code> in this package. Follow
  * the pattern from an existing class such as {@link RelMdColumnOrigins},
  * overloading on all of the logical relational expressions to which the query
@@ -65,22 +67,6 @@ public abstract class RelMetadataQuery {
   //~ Methods ----------------------------------------------------------------
 
   /**
-   * Returns statistics for a relational expression. These statistics include
-   * features such as row counts, or column distributions. Stats are typically
-   * collected by sampling a table. They might also be inferred from a rel's
-   * history. Certain rels, such as filters, might generate stats from their
-   * inputs.
-   *
-   * @param rel the relational expression.
-   * @return a statistics object, if statistics are available, or null
-   * otherwise
-   */
-  @Deprecated
-  public static RelStatSource getStatistics(RelNode rel) {
-    throw new UnsupportedOperationException();
-  }
-
-  /**
    * Returns the
    * {@link BuiltInMetadata.RowCount#getRowCount()}
    * statistic.
@@ -162,7 +148,7 @@ public abstract class RelMetadataQuery {
    * Determines the origin of a column, provided the column maps to a single
    * column that isn't derived.
    *
-   * @see #getColumnOrigins(org.eigenbase.rel.RelNode, int)
+   * @see #getColumnOrigins(org.apache.calcite.rel.RelNode, int)
    *
    * @param rel the RelNode of the column
    * @param column the offset of the column whose origin we are trying to
@@ -329,7 +315,7 @@ public abstract class RelMetadataQuery {
 
   /**
    * Returns the
-   * {@link org.eigenbase.rel.metadata.BuiltInMetadata.Predicates#getPredicates()}
+   * {@link org.apache.calcite.rel.metadata.BuiltInMetadata.Predicates#getPredicates()}
    * statistic.
    *
    * @param rel the relational expression

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/metadata/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/package-info.java b/core/src/main/java/org/apache/calcite/rel/metadata/package-info.java
index 6d865ff..ed98035 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/package-info.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/package-info.java
@@ -19,6 +19,6 @@
  * Defines metadata interfaces and utilities for relational
  * expressions.
  */
-package org.eigenbase.rel.metadata;
+package org.apache.calcite.rel.metadata;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/package-info.java b/core/src/main/java/org/apache/calcite/rel/package-info.java
index da6776e..fdbfd3b 100644
--- a/core/src/main/java/org/apache/calcite/rel/package-info.java
+++ b/core/src/main/java/org/apache/calcite/rel/package-info.java
@@ -20,20 +20,21 @@
  *
  * <h2>Related packages and classes</h2>
  * <ul>
- *     <li>Package<code> <a
- *             href="../sql/package-summary.html">org.eigenbase.sql</a></code>
- *         is an object model for SQL expressions
- *     </li>
- *     <li>Package<code> <a
- *             href="../sql/package-summary.html">org.eigenbase.rex</a></code>
- *         is an object model for relational row expressions
- *     </li>
- *     <li>Package<code> <a href="../relopt/package-summary.html">
- *         org.eigenbase.relopt</a></code>
- *         provides an optimizer interface.
- *     </li>
+ *
+ * <li>Package <code>
+ * <a href="../sql/package-summary.html">org.apache.calcite.sql</a></code>
+ * is an object model for SQL expressions
+ *
+ * <li>Package <code>
+ * <a href="../sql/package-summary.html">org.apache.calcite.rex</a></code>
+ * is an object model for relational row expressions
+ *
+ * <li>Package <code>
+ * <a href="../plan/package-summary.html">org.apache.calcite.plan</a></code>
+ * provides an optimizer interface.
+ *
  * </ul>
  */
-package org.eigenbase.rel;
+package org.apache.calcite.rel;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java b/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
index 39928cd..915ae87 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
@@ -14,39 +14,69 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.rules;
-
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.relopt.*;
-import org.eigenbase.reltype.*;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.fun.*;
-import org.eigenbase.util.*;
-
-import net.hydromatic.optiq.util.BitSets;
+package org.apache.calcite.rel.rules;
+
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.core.RelFactories;
+import org.apache.calcite.rel.logical.LogicalAggregate;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
- * Rule to remove distinct aggregates from a {@link AggregateRel}.
+ * Planner rule that expands distinct aggregates
+ * (such as {@code COUNT(DISTINCT x)}) from a
+ * {@link org.apache.calcite.rel.logical.LogicalAggregate}.
+ *
+ * <p>How this is done depends upon the arguments to the function. If all
+ * functions have the same argument
+ * (e.g. {@code COUNT(DISTINCT x), SUM(DISTINCT x)} both have the argument
+ * {@code x}) then one extra {@link org.apache.calcite.rel.core.Aggregate} is
+ * sufficient.
+ *
+ * <p>If there are multiple arguments
+ * (e.g. {@code COUNT(DISTINCT x), COUNT(DISTINCT y)})
+ * the rule creates separate {@code Aggregate}s and combines using a
+ * {@link org.apache.calcite.rel.core.Join}.
  */
-public final class RemoveDistinctAggregateRule extends RelOptRule {
+public final class AggregateExpandDistinctAggregatesRule extends RelOptRule {
   //~ Static fields/initializers ---------------------------------------------
 
   /** The default instance of the rule; operates only on logical expressions. */
-  public static final RemoveDistinctAggregateRule INSTANCE =
-      new RemoveDistinctAggregateRule(AggregateRel.class,
+  public static final AggregateExpandDistinctAggregatesRule INSTANCE =
+      new AggregateExpandDistinctAggregatesRule(LogicalAggregate.class,
           RelFactories.DEFAULT_JOIN_FACTORY);
 
   private final RelFactories.JoinFactory joinFactory;
 
   //~ Constructors -----------------------------------------------------------
 
-  public RemoveDistinctAggregateRule(Class<? extends AggregateRel> clazz,
+  public AggregateExpandDistinctAggregatesRule(
+      Class<? extends LogicalAggregate> clazz,
       RelFactories.JoinFactory joinFactory) {
     super(operand(clazz, any()));
     this.joinFactory = joinFactory;
@@ -55,7 +85,7 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
   //~ Methods ----------------------------------------------------------------
 
   public void onMatch(RelOptRuleCall call) {
-    final AggregateRelBase aggregate = call.rel(0);
+    final Aggregate aggregate = call.rel(0);
     if (!aggregate.containsDistinctCall()) {
       return;
     }
@@ -125,9 +155,9 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
       rel = null;
     } else {
       rel =
-          new AggregateRel(
+          new LogicalAggregate(
               aggregate.getCluster(),
-              aggregate.getChild(),
+              aggregate.getInput(),
               groupSet,
               newAggCallList);
     }
@@ -149,7 +179,7 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
    * and no non-distinct aggregate functions.
    */
   private RelNode convertMonopole(
-      AggregateRelBase aggregate,
+      Aggregate aggregate,
       List<Integer> argList) {
     // For example,
     //    SELECT deptno, COUNT(DISTINCT sal), SUM(DISTINCT sal)
@@ -167,7 +197,7 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
     // Project the columns of the GROUP BY plus the arguments
     // to the agg function.
     Map<Integer, Integer> sourceOf = new HashMap<Integer, Integer>();
-    final AggregateRelBase distinct =
+    final Aggregate distinct =
         createSelectDistinct(aggregate, argList, sourceOf);
 
     // Create an aggregate on top, with the new aggregate list.
@@ -201,7 +231,7 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
    * @return Relational expression
    */
   private RelNode doRewrite(
-      AggregateRelBase aggregate,
+      Aggregate aggregate,
       RelNode left,
       List<Integer> argList,
       List<RexInputRef> refs) {
@@ -213,16 +243,16 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
       leftFields = left.getRowType().getFieldList();
     }
 
-    // AggregateRel(
+    // LogicalAggregate(
     //     child,
     //     {COUNT(DISTINCT 1), SUM(DISTINCT 1), SUM(2)})
     //
     // becomes
     //
-    // AggregateRel(
-    //     JoinRel(
+    // LogicalAggregate(
+    //     LogicalJoin(
     //         child,
-    //         AggregateRel(child, < all columns > {}),
+    //         LogicalAggregate(child, < all columns > {}),
     //         INNER,
     //         <f2 = f5>))
     //
@@ -257,7 +287,7 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
     // Project the columns of the GROUP BY plus the arguments
     // to the agg function.
     Map<Integer, Integer> sourceOf = new HashMap<Integer, Integer>();
-    final AggregateRelBase distinct =
+    final Aggregate distinct =
         createSelectDistinct(aggregate, argList, sourceOf);
 
     // Now compute the aggregate functions on top of the distinct dataset.
@@ -312,7 +342,7 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
       aggCallList.add(newAggCall);
     }
 
-    AggregateRelBase distinctAgg =
+    Aggregate distinctAgg =
         aggregate.copy(
             aggregate.getTraitSet(),
             distinct,
@@ -390,7 +420,8 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
   }
 
   /**
-   * Given an {@link AggregateRel} and the ordinals of the arguments to a
+   * Given an {@link org.apache.calcite.rel.logical.LogicalAggregate}
+   * and the ordinals of the arguments to a
    * particular call to an aggregate function, creates a 'select distinct'
    * relational expression which projects the group columns and those
    * arguments but nothing else.
@@ -424,13 +455,13 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
    * @return Aggregate relational expression which projects the required
    * columns
    */
-  private static AggregateRelBase createSelectDistinct(
-      AggregateRelBase aggregate,
+  private static Aggregate createSelectDistinct(
+      Aggregate aggregate,
       List<Integer> argList,
       Map<Integer, Integer> sourceOf) {
     final List<Pair<RexNode, String>> projects =
         new ArrayList<Pair<RexNode, String>>();
-    final RelNode child = aggregate.getChild();
+    final RelNode child = aggregate.getInput();
     final List<RelDataTypeField> childFields =
         child.getRowType().getFieldList();
     for (int i : BitSets.toIter(aggregate.getGroupSet())) {
@@ -457,4 +488,4 @@ public final class RemoveDistinctAggregateRule extends RelOptRule {
   }
 }
 
-// End RemoveDistinctAggregateRule.java
+// End AggregateExpandDistinctAggregatesRule.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/rules/AggregateFilterTransposeRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/AggregateFilterTransposeRule.java b/core/src/main/java/org/apache/calcite/rel/rules/AggregateFilterTransposeRule.java
index c7b4f73..4b909cc 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/AggregateFilterTransposeRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/AggregateFilterTransposeRule.java
@@ -14,34 +14,33 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.rules;
+package org.apache.calcite.rel.rules;
 
-import java.util.BitSet;
-import java.util.List;
-
-import org.eigenbase.rel.AggregateCall;
-import org.eigenbase.rel.AggregateRelBase;
-import org.eigenbase.rel.Aggregation;
-import org.eigenbase.rel.FilterRelBase;
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.rel.metadata.RelMetadataQuery;
-import org.eigenbase.relopt.RelOptRule;
-import org.eigenbase.relopt.RelOptRuleCall;
-import org.eigenbase.relopt.RelOptUtil;
-import org.eigenbase.relopt.SubstitutionVisitor;
-import org.eigenbase.rex.RexNode;
-import org.eigenbase.rex.RexUtil;
-import org.eigenbase.util.mapping.Mappings;
-
-import net.hydromatic.optiq.util.BitSets;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.plan.SubstitutionVisitor;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.SqlAggFunction;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.mapping.Mappings;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
+import java.util.BitSet;
+import java.util.List;
+
 /**
- * Planner rule that matches an {@link org.eigenbase.rel.AggregateRelBase}
- * on a {@link org.eigenbase.rel.FilterRelBase} and transposes them,
+ * Planner rule that matches an {@link org.apache.calcite.rel.core.Aggregate}
+ * on a {@link org.apache.calcite.rel.core.Filter} and transposes them,
  * pushing the aggregate below the filter.
  *
  * <p>In some cases, it is necessary to split the aggregate.
@@ -52,7 +51,7 @@ import com.google.common.collect.Lists;
  * evaluate. The main use of the rule is to match a query that has a filter
  * under an aggregate to an existing aggregate table.
  *
- * @see org.eigenbase.rel.rules.FilterAggregateTransposeRule
+ * @see org.apache.calcite.rel.rules.FilterAggregateTransposeRule
  */
 public class AggregateFilterTransposeRule extends RelOptRule {
   public static final AggregateFilterTransposeRule INSTANCE =
@@ -60,20 +59,20 @@ public class AggregateFilterTransposeRule extends RelOptRule {
 
   private AggregateFilterTransposeRule() {
     super(
-        operand(AggregateRelBase.class,
-            operand(FilterRelBase.class, any())));
+        operand(Aggregate.class,
+            operand(Filter.class, any())));
   }
 
   public void onMatch(RelOptRuleCall call) {
-    final AggregateRelBase aggregate = call.rel(0);
-    final FilterRelBase filter = call.rel(1);
+    final Aggregate aggregate = call.rel(0);
+    final Filter filter = call.rel(1);
 
     // Do the columns used by the filter appear in the output of the aggregate?
     final BitSet filterColumns =
         RelOptUtil.InputFinder.bits(filter.getCondition());
     final BitSet newGroupSet =
         BitSets.union(aggregate.getGroupSet(), filterColumns);
-    final RelNode input = filter.getChild();
+    final RelNode input = filter.getInput();
     final Boolean unique =
         RelMetadataQuery.areColumnsUnique(input, newGroupSet);
     if (unique != null && unique) {
@@ -82,7 +81,7 @@ public class AggregateFilterTransposeRule extends RelOptRule {
       // the rule fires forever: A-F => A-F-A => A-A-F-A => A-A-A-F-A => ...
       return;
     }
-    final AggregateRelBase newAggregate =
+    final Aggregate newAggregate =
         aggregate.copy(aggregate.getTraitSet(), input, newGroupSet,
             aggregate.getAggCallList());
     final Mappings.TargetMapping mapping = Mappings.target(
@@ -95,7 +94,7 @@ public class AggregateFilterTransposeRule extends RelOptRule {
         newGroupSet.cardinality());
     final RexNode newCondition =
         RexUtil.apply(mapping, filter.getCondition());
-    final FilterRelBase newFilter = filter.copy(filter.getTraitSet(),
+    final Filter newFilter = filter.copy(filter.getTraitSet(),
         newAggregate, newCondition);
     if (BitSets.contains(aggregate.getGroupSet(), filterColumns)) {
       // Everything needed by the filter is returned by the aggregate.
@@ -111,7 +110,7 @@ public class AggregateFilterTransposeRule extends RelOptRule {
       final List<AggregateCall> topAggCallList = Lists.newArrayList();
       int i = newGroupSet.cardinality();
       for (AggregateCall aggregateCall : aggregate.getAggCallList()) {
-        final Aggregation rollup =
+        final SqlAggFunction rollup =
             SubstitutionVisitor.getRollup(aggregateCall.getAggregation());
         if (rollup == null) {
           // This aggregate cannot be rolled up.
@@ -125,7 +124,7 @@ public class AggregateFilterTransposeRule extends RelOptRule {
             new AggregateCall(rollup, aggregateCall.isDistinct(),
                 ImmutableList.of(i++), aggregateCall.type, aggregateCall.name));
       }
-      final AggregateRelBase topAggregate =
+      final Aggregate topAggregate =
           aggregate.copy(aggregate.getTraitSet(), newFilter, topGroupSet,
               topAggCallList);
       call.transformTo(topAggregate);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/rel/rules/AggregateProjectMergeRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/AggregateProjectMergeRule.java b/core/src/main/java/org/apache/calcite/rel/rules/AggregateProjectMergeRule.java
index c97a8c9..8b1dafc 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/AggregateProjectMergeRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/AggregateProjectMergeRule.java
@@ -14,30 +14,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.rel.rules;
+package org.apache.calcite.rel.rules;
 
-import java.util.BitSet;
-import java.util.List;
-
-import org.eigenbase.rel.AggregateCall;
-import org.eigenbase.rel.AggregateRelBase;
-import org.eigenbase.rel.ProjectRelBase;
-import org.eigenbase.rel.RelFactories;
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.relopt.RelOptRule;
-import org.eigenbase.relopt.RelOptRuleCall;
-import org.eigenbase.relopt.RelOptUtil;
-import org.eigenbase.rex.RexInputRef;
-import org.eigenbase.rex.RexNode;
-
-import net.hydromatic.optiq.util.BitSets;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.core.RelFactories;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.util.BitSets;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
+import java.util.BitSet;
+import java.util.List;
+
 /**
- * Planner rule that recognizes a {@link org.eigenbase.rel.AggregateRelBase}
- * on top of a {@link org.eigenbase.rel.ProjectRelBase} and if possible
+ * Planner rule that recognizes a {@link org.apache.calcite.rel.core.Aggregate}
+ * on top of a {@link org.apache.calcite.rel.core.Project} and if possible
  * aggregate through the project or removes the project.
  *
  * <p>This is only possible when the grouping expressions and arguments to
@@ -53,21 +52,21 @@ public class AggregateProjectMergeRule extends RelOptRule {
   /** Private constructor. */
   private AggregateProjectMergeRule() {
     super(
-        operand(AggregateRelBase.class,
-            operand(ProjectRelBase.class, any())));
+        operand(Aggregate.class,
+            operand(Project.class, any())));
   }
 
   public void onMatch(RelOptRuleCall call) {
-    final AggregateRelBase aggregate = call.rel(0);
-    final ProjectRelBase project = call.rel(1);
+    final Aggregate aggregate = call.rel(0);
+    final Project project = call.rel(1);
     RelNode x = apply(aggregate, project);
     if (x != null) {
       call.transformTo(x);
     }
   }
 
-  public static RelNode apply(AggregateRelBase aggregate,
-      ProjectRelBase project) {
+  public static RelNode apply(Aggregate aggregate,
+      Project project) {
     final List<Integer> newKeys = Lists.newArrayList();
     for (int key : BitSets.toIter(aggregate.getGroupSet())) {
       final RexNode rex = project.getProjects().get(key);
@@ -96,8 +95,8 @@ public class AggregateProjectMergeRule extends RelOptRule {
     }
 
     final BitSet newGroupSet = BitSets.of(newKeys);
-    final AggregateRelBase newAggregate =
-        aggregate.copy(aggregate.getTraitSet(), project.getChild(), newGroupSet,
+    final Aggregate newAggregate =
+        aggregate.copy(aggregate.getTraitSet(), project.getInput(), newGroupSet,
             aggCalls.build());
 
     // Add a project if the group set is not in the same order or


Mime
View raw message