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/06/13 02:38:10 UTC

[6/7] incubator-calcite git commit: Fix coverity warnings

Fix coverity warnings


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

Branch: refs/heads/master
Commit: 2b2176577c9c36466772eee8636dca159bcc5d9a
Parents: 6718963
Author: Julian Hyde <jh...@apache.org>
Authored: Thu Jun 11 23:12:26 2015 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Jun 11 23:46:07 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/calcite/schema/Schemas.java | 11 ++++++++++-
 .../main/java/org/apache/calcite/tools/RelBuilder.java   |  5 +++--
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/2b217657/core/src/main/java/org/apache/calcite/schema/Schemas.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/Schemas.java b/core/src/main/java/org/apache/calcite/schema/Schemas.java
index 7c09ffb..aa53419 100644
--- a/core/src/main/java/org/apache/calcite/schema/Schemas.java
+++ b/core/src/main/java/org/apache/calcite/schema/Schemas.java
@@ -473,9 +473,18 @@ public final class Schemas {
     }
   }
 
+  /** Returns a sub-schema of a given schema obtained by following a sequence
+   * of names.
+   *
+   * <p>The result is null if the initial schema is null or any sub-schema does
+   * not exist.
+   */
   public static CalciteSchema subSchema(CalciteSchema schema,
-        List<String> names) {
+      Iterable<String> names) {
     for (String string : names) {
+      if (schema == null) {
+        return null;
+      }
       schema = schema.getSubSchema(string, false);
     }
     return schema;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/2b217657/core/src/main/java/org/apache/calcite/tools/RelBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/RelBuilder.java b/core/src/main/java/org/apache/calcite/tools/RelBuilder.java
index ce185d8..f664baf 100644
--- a/core/src/main/java/org/apache/calcite/tools/RelBuilder.java
+++ b/core/src/main/java/org/apache/calcite/tools/RelBuilder.java
@@ -864,14 +864,15 @@ public class RelBuilder {
     }
     final RexNode offsetNode = offset <= 0 ? null : literal(offset);
     final RexNode fetchNode = fetch < 0 ? null : literal(fetch);
-    if (extraNodes.size() > inputRowType.getFieldCount()) {
+    final boolean addedFields = extraNodes.size() > originalExtraNodes.size();
+    if (addedFields) {
       project(extraNodes);
     }
     final RelNode sort =
         sortFactory.createSort(build(), RelCollations.of(fieldCollations),
             offsetNode, fetchNode);
     push(sort);
-    if (extraNodes.size() > inputRowType.getFieldCount()) {
+    if (addedFields) {
       project(originalExtraNodes);
     }
     return this;