You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/12/04 21:51:46 UTC

calcite git commit: [CALCITE-1005] Handle null in getMaxRowCount for Aggregate (Mike Hinchey)

Repository: calcite
Updated Branches:
  refs/heads/master cd58fe73f -> b0fa9f379


[CALCITE-1005] Handle null in getMaxRowCount for Aggregate (Mike Hinchey)

Close apache/calcite#173


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

Branch: refs/heads/master
Commit: b0fa9f379a2ed4426130bc565c55af74becbcd25
Parents: cd58fe7
Author: Mike Hinchey <hi...@gmail.com>
Authored: Thu Dec 3 23:31:41 2015 -0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Fri Dec 4 11:03:23 2015 -0800

----------------------------------------------------------------------
 .../org/apache/calcite/rel/metadata/RelMdMaxRowCount.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/b0fa9f37/core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java
index c8e84cc..c7b3b75 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java
@@ -97,10 +97,14 @@ public class RelMdMaxRowCount {
 
   public Double getMaxRowCount(Aggregate rel) {
     if (rel.getGroupSet().isEmpty()) {
+      // Aggregate with no GROUP BY always returns 1 row (even on empty table).
       return 1D;
     }
-    return RelMetadataQuery.getMaxRowCount(rel.getInput())
-        * rel.getGroupSets().size();
+    final Double rowCount = RelMetadataQuery.getMaxRowCount(rel.getInput());
+    if (rowCount == null) {
+      return null;
+    }
+    return rowCount * rel.getGroupSets().size();
   }
 
   public Double getMaxRowCount(Join rel) {