calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [1/3] incubator-calcite git commit: Fix traits in MongoDB adapter, and NPE in JdbcTest
Date Tue, 07 Apr 2015 20:45:20 GMT
Repository: incubator-calcite
Updated Branches:
  refs/heads/master e48c7627c -> a00e45219


Fix traits in MongoDB adapter, and NPE in JdbcTest


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

Branch: refs/heads/master
Commit: 65774b056bcd277634e0fc6f678806f15ba05e83
Parents: e48c762
Author: Julian Hyde <jhyde@apache.org>
Authored: Mon Apr 6 16:11:40 2015 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Tue Apr 7 12:23:04 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/calcite/test/JdbcTest.java   | 12 ++++++++----
 .../calcite/adapter/mongodb/MongoRules.java      |  4 ++--
 .../apache/calcite/test/MongoAdapterTest.java    | 19 ++++++++++++++-----
 3 files changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/65774b05/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index 730c672..0f0e162 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -192,13 +192,17 @@ public class JdbcTest {
       + "   ]\n"
       + "}";
 
+  private static final ConnectionSpec SCOTT =
+      Util.first(CalciteAssert.DB.scott,
+          CalciteAssert.DatabaseInstance.HSQLDB.scott);
+
   public static final String SCOTT_SCHEMA = "     {\n"
       + "       type: 'jdbc',\n"
       + "       name: 'SCOTT',\n"
-      + "       jdbcDriver: '" + CalciteAssert.DB.scott.driver + "',\n"
-      + "       jdbcUser: '" + CalciteAssert.DB.scott.username + "',\n"
-      + "       jdbcPassword: '" + CalciteAssert.DB.scott.password + "',\n"
-      + "       jdbcUrl: '" + CalciteAssert.DB.scott.url + "',\n"
+      + "       jdbcDriver: '" + SCOTT.driver + "',\n"
+      + "       jdbcUser: '" + SCOTT.username + "',\n"
+      + "       jdbcPassword: '" + SCOTT.password + "',\n"
+      + "       jdbcUrl: '" + SCOTT.url + "',\n"
       + "       jdbcCatalog: null,\n"
       + "       jdbcSchema: 'SCOTT'\n"
       + "     }\n";

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/65774b05/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
index 0ccee35..0249cce 100644
--- a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
+++ b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
@@ -239,7 +239,7 @@ public class MongoRules {
       return new MongoFilter(
           rel.getCluster(),
           traitSet,
-          convert(filter.getInput(), traitSet),
+          convert(filter.getInput(), out),
           filter.getCondition());
     }
   }
@@ -260,7 +260,7 @@ public class MongoRules {
       final LogicalProject project = (LogicalProject) rel;
       final RelTraitSet traitSet = project.getTraitSet().replace(out);
       return new MongoProject(project.getCluster(), traitSet,
-          convert(project.getInput(), traitSet), project.getProjects(),
+          convert(project.getInput(), out), project.getProjects(),
           project.getRowType());
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/65774b05/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterTest.java
----------------------------------------------------------------------
diff --git a/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterTest.java b/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterTest.java
index bdb9a87..bc9a9dc 100644
--- a/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterTest.java
+++ b/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterTest.java
@@ -530,8 +530,15 @@ public class MongoAdapterTest {
             + " min(pop) as min_pop, max(pop) as max_pop, sum(pop) as sum_pop\n"
             + "from zips group by state")
         .limit(2)
-        .returns("C=659; STATE=WV; MIN_POP=0; MAX_POP=70185; SUM_POP=1793477\n"
-            + "C=484; STATE=WA; MIN_POP=2; MAX_POP=50515; SUM_POP=4866692\n");
+        .returns("C=195; STATE=AK; MIN_POP=0; MAX_POP=32383; SUM_POP=544698\n"
+            + "C=567; STATE=AL; MIN_POP=0; MAX_POP=44165; SUM_POP=4040587\n")
+        .queryContains(
+            mongoChecker(
+                "{$project: {STATE: '$state', POP: '$pop'}}",
+                "{$group: {_id: '$STATE', C: {$sum: 1}, MIN_POP: {$min: '$POP'}, MAX_POP:
{$max: '$POP'}, SUM_POP: {$sum: '$POP'}}}",
+                "{$project: {STATE: '$_id', C: '$C', MIN_POP: '$MIN_POP', MAX_POP: '$MAX_POP',
SUM_POP: '$SUM_POP'}}",
+                "{$project: {C: 1, STATE: 1, MIN_POP: 1, MAX_POP: 1, SUM_POP: 1}}",
+                "{$sort: {STATE: 1}}"));
   }
 
   @Test public void testGroupComposite() {
@@ -547,9 +554,9 @@ public class MongoAdapterTest {
                 "{$project: {STATE: '$state', CITY: '$city'}}",
                 "{$group: {_id: {STATE: '$STATE', CITY: '$CITY'}, C: {$sum: 1}}}",
                 "{$project: {_id: 0, STATE: '$_id.STATE', CITY: '$_id.CITY', C: '$C'}}",
-                "{$project: {C: 1, STATE: 1, CITY: 1}}",
                 "{$sort: {C: -1}}",
-                "{$limit: 2}"));
+                "{$limit: 2}",
+                "{$project: {C: 1, STATE: 1, CITY: 1}}"));
   }
 
   @Test public void testDistinctCount() {
@@ -615,7 +622,9 @@ public class MongoAdapterTest {
             + "STATE=AL; CITY=ADAMSVILLE; ZERO=0\n")
         .queryContains(
             mongoChecker(
-                "{$project: {STATE: '$state', CITY: '$city', ZERO: {$ifNull: [null, 0]}}}"));
+                "{$project: {CITY: '$city', STATE: '$state'}}",
+                "{$sort: {STATE: 1, CITY: 1}}",
+                "{$project: {STATE: 1, CITY: 1, ZERO: {$ifNull: [null, 0]}}}"));
   }
 
   @Test public void testFilter() {


Mime
View raw message