You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2015/07/20 15:34:56 UTC

phoenix git commit: Add ExpressionFactoryValuesTest

Repository: phoenix
Updated Branches:
  refs/heads/calcite c8c7f0df6 -> 0641043a4


Add ExpressionFactoryValuesTest


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

Branch: refs/heads/calcite
Commit: 0641043a4dda12b399f914c7281846fa7fbd407d
Parents: c8c7f0d
Author: maryannxue <we...@intel.com>
Authored: Mon Jul 20 09:34:34 2015 -0400
Committer: maryannxue <we...@intel.com>
Committed: Mon Jul 20 09:34:34 2015 -0400

----------------------------------------------------------------------
 phoenix-core/pom.xml                            |  5 ++
 .../calcite/jdbc/PhoenixPrepareImpl.java        |  2 -
 .../phoenix/calcite/rel/PhoenixValues.java      |  7 +++
 .../calcite/rules/PhoenixConverterRules.java    | 59 +++++++-------------
 .../calcite/ExpressionFactoryValuesTest.java    | 23 ++++++++
 pom.xml                                         |  6 ++
 6 files changed, 60 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0641043a/phoenix-core/pom.xml
----------------------------------------------------------------------
diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml
index 2f8f006..b5d3cbf 100644
--- a/phoenix-core/pom.xml
+++ b/phoenix-core/pom.xml
@@ -351,6 +351,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.calcite</groupId>
+      <artifactId>calcite-core</artifactId>
+      <type>test-jar</type>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.calcite</groupId>
       <artifactId>calcite-linq4j</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0641043a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
index 5cc911d..828497f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
@@ -1,7 +1,5 @@
 package org.apache.phoenix.calcite.jdbc;
 
-import java.util.Map;
-
 import org.apache.calcite.jdbc.CalcitePrepare;
 import org.apache.calcite.jdbc.CalciteSchema;
 import org.apache.calcite.plan.RelOptCostFactory;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0641043a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
index c982a28..6cb9f1a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
@@ -3,6 +3,8 @@ package org.apache.phoenix.calcite.rel;
 import java.util.List;
 
 import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptCost;
+import org.apache.calcite.plan.RelOptPlanner;
 import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Values;
@@ -34,6 +36,11 @@ public class PhoenixValues extends Values implements PhoenixRel {
     }
 
     @Override
+    public RelOptCost computeSelfCost(RelOptPlanner planner) {
+        return super.computeSelfCost(planner).multiplyBy(PHOENIX_FACTOR);
+    }
+
+    @Override
     public QueryPlan implement(Implementor implementor) {
         throw new UnsupportedOperationException();
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0641043a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java
index ea34a1e..44ac971 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java
@@ -25,6 +25,7 @@ import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.Project;
 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.rel.logical.LogicalAggregate;
 import org.apache.calcite.rel.logical.LogicalFilter;
 import org.apache.calcite.rel.logical.LogicalJoin;
@@ -49,6 +50,7 @@ import org.apache.phoenix.calcite.rel.PhoenixServerSort;
 import org.apache.phoenix.calcite.rel.PhoenixToClientConverter;
 import org.apache.phoenix.calcite.rel.PhoenixToEnumerableConverter;
 import org.apache.phoenix.calcite.rel.PhoenixUnion;
+import org.apache.phoenix.calcite.rel.PhoenixValues;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -81,6 +83,7 @@ public class PhoenixConverterRules {
         PhoenixUnionRule.INSTANCE,
         PhoenixClientJoinRule.INSTANCE,
         PhoenixServerJoinRule.INSTANCE,
+        PhoenixValuesRule.INSTANCE,
     };
 
     /** Base class for planner rules that convert a relational expression to
@@ -531,6 +534,22 @@ public class PhoenixConverterRules {
         }
     }
 
+    public static class PhoenixValuesRule extends PhoenixConverterRule {
+        public static PhoenixValuesRule INSTANCE = new PhoenixValuesRule();
+        
+        private PhoenixValuesRule() {
+            super(Values.class, Convention.NONE, PhoenixRel.CLIENT_CONVENTION, "PhoenixValuesRule");
+        }
+
+        @Override public RelNode convert(RelNode rel) {
+            Values valuesRel = (Values) rel;
+            return PhoenixValues.create(
+                    valuesRel.getCluster(),
+                    valuesRel.getRowType(),
+                    valuesRel.getTuples());
+        }
+    }
+
     /**
      * Rule to convert an {@link org.apache.calcite.rel.logical.LogicalIntersect}
      * to an {@link PhoenixIntersectRel}.
@@ -634,46 +653,6 @@ public class PhoenixConverterRules {
      }
      */
 
-  /*
-  public static class PhoenixValuesRule extends PhoenixConverterRule {
-    private PhoenixValuesRule() {
-      super(Values.class, Convention.NONE, PhoenixRel.CONVENTION, "PhoenixValuesRule");
-    }
-
-    @Override public RelNode convert(RelNode rel) {
-      Values valuesRel = (Values) rel;
-      return new PhoenixValuesRel(
-          valuesRel.getCluster(),
-          valuesRel.getRowType(),
-          valuesRel.getTuples(),
-          valuesRel.getTraitSet().plus(out));
-    }
-  }
-
-  public static class PhoenixValuesRel
-      extends Values
-      implements PhoenixRel {
-    PhoenixValuesRel(
-        RelOptCluster cluster,
-        RelDataType rowType,
-        List<List<RexLiteral>> tuples,
-        RelTraitSet traitSet) {
-      super(cluster, rowType, tuples, traitSet);
-    }
-
-    @Override public RelNode copy(
-        RelTraitSet traitSet, List<RelNode> inputs) {
-      assert inputs.isEmpty();
-      return new PhoenixValuesRel(
-          getCluster(), rowType, tuples, traitSet);
-    }
-
-    public SqlString implement(PhoenixImplementor implementor) {
-      throw new AssertionError(); // TODO:
-    }
-  }
-*/
-
     /**
      * Rule to convert a relational expression from
      * {@link org.apache.phoenix.calcite.rel.PhoenixRel#SERVER_CONVENTION} to

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0641043a/phoenix-core/src/test/java/org/apache/phoenix/calcite/ExpressionFactoryValuesTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/calcite/ExpressionFactoryValuesTest.java b/phoenix-core/src/test/java/org/apache/phoenix/calcite/ExpressionFactoryValuesTest.java
new file mode 100644
index 0000000..59faa03
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/calcite/ExpressionFactoryValuesTest.java
@@ -0,0 +1,23 @@
+package org.apache.phoenix.calcite;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.calcite.sql.test.SqlOperatorBaseTest;
+
+public class ExpressionFactoryValuesTest extends SqlOperatorBaseTest {
+    private static final ThreadLocal<Connection> LOCAL =
+            new ThreadLocal<Connection>() {
+        @Override protected Connection initialValue() {
+            try {
+                return DriverManager.getConnection("jdbc:phoenixcalcite:");
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+    };
+
+    public ExpressionFactoryValuesTest() {
+        super(false, tester(LOCAL.get()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0641043a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3ff1ad4..fbdf9de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -782,6 +782,12 @@
         <version>${calcite.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.calcite</groupId>
+        <artifactId>calcite-core</artifactId>
+        <version>${calcite.version}</version>
+        <type>test-jar</type>
+      </dependency>
+      <dependency>
         <groupId>net.hydromatic</groupId>
         <artifactId>foodmart-data-hsqldb</artifactId>
         <version>0.3</version>