[CALCITE-1925] In JaninoRelMetadataProvider, cache null values (Ted Xu)

Close apache/calcite#507


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

Branch: refs/heads/master
Commit: eaa56413afa863bf93ccfc93132e0e43deaac8dd
Parents: e43520a
Author: Ted Xu <frank...@gmail.com>
Authored: Fri Aug 4 16:31:41 2017 +0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Mon Aug 7 10:17:28 2017 -0700

----------------------------------------------------------------------
 .../calcite/rel/metadata/JaninoRelMetadataProvider.java     | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/eaa56413/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
 
b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
index 73baf77..5fff97a 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
@@ -275,6 +275,11 @@ public class JaninoRelMetadataProvider implements 
RelMetadataProvider {
           .append(CyclicMetadataException.class.getName())
           .append(".INSTANCE;\n")
           .append("      }\n")
+          .append("      if (v == ")
+          .append(NullSentinel.class.getName())
+          .append(".INSTANCE) {\n")
+          .append("        return null;\n")
+          .append("      }\n")
           .append("      return (")
           .append(method.e.getReturnType().getName())
           .append(") v;\n")
@@ -290,7 +295,9 @@ public class JaninoRelMetadataProvider implements 
RelMetadataProvider {
           .append("_(r, mq");
       argList(buff, method.e)
           .append(");\n")
-          .append("      mq.map.put(key, x);\n")
+          .append("      mq.map.put(key, ")
+          .append(NullSentinel.class.getName())
+          .append(".mask(x));\n")
           .append("      return x;\n")
           .append("    } catch (")
           .append(Exception.class.getName())

Reply via email to