tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject tajo git commit: TAJO-1620: random() in an SQL should generate RANDOM numbers.
Date Mon, 25 May 2015 13:56:53 GMT
Repository: tajo
Updated Branches:
  refs/heads/master c1fe41a09 -> bbfa076e1


TAJO-1620: random() in an SQL should generate RANDOM numbers.

Closes #582

Signed-off-by: Jihoon Son <jihoonson@apache.org>


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

Branch: refs/heads/master
Commit: bbfa076e1c2f379116d276d4b939fb757d798e2e
Parents: c1fe41a
Author: Jongyoung Park <eminency@gmail.com>
Authored: Mon May 25 22:56:27 2015 +0900
Committer: Jihoon Son <jihoonson@apache.org>
Committed: Mon May 25 22:56:27 2015 +0900

----------------------------------------------------------------------
 CHANGES                                                   |  3 +++
 .../tajo/plan/exprrewrite/rules/ConstantFolding.java      | 10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/bbfa076e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 991040a..f1b7e6e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -136,6 +136,9 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1620: random() in an SQL should generate RANDOM numbers.
+    (Contributed by Jongyoung Park, Committed by jihoon)
+
     TAJO-1558: HBASE_LIB/hbase-server-*.jar should be included in the CLASSPATH.
     (Contributed by Jongyoung Park, Committed by jaehwa)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/bbfa076e/tajo-plan/src/main/java/org/apache/tajo/plan/exprrewrite/rules/ConstantFolding.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/exprrewrite/rules/ConstantFolding.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/exprrewrite/rules/ConstantFolding.java
index a8b0945..eb546d1 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/exprrewrite/rules/ConstantFolding.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/exprrewrite/rules/ConstantFolding.java
@@ -27,14 +27,15 @@ import org.apache.tajo.plan.function.python.PythonScriptEngine;
 import org.apache.tajo.plan.function.python.TajoScriptEngine;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.Stack;
 
 @Prioritized(priority = 10)
 public class ConstantFolding extends SimpleEvalNodeVisitor<LogicalPlanner.PlanContext>
     implements EvalTreeOptimizationRule {
 
-  private final static String SLEEP_FUNCTION_NAME = "sleep";
-
   @Override
   public EvalNode optimize(LogicalPlanner.PlanContext context, EvalNode evalNode) {
     return visit(context, evalNode, new Stack<EvalNode>());
@@ -77,11 +78,14 @@ public class ConstantFolding extends SimpleEvalNodeVisitor<LogicalPlanner.PlanCo
     return unaryEval;
   }
 
+  // exceptional func names not to use constant folding
+  private static final Set<String> NON_CONSTANT_FUNC_NAMES = new HashSet<String>(Arrays.asList("sleep",
"random"));
+
   @Override
   public EvalNode visitFuncCall(LogicalPlanner.PlanContext context, FunctionEval evalNode,
Stack<EvalNode> stack) {
     boolean constantOfAllDescendents = true;
 
-    if (SLEEP_FUNCTION_NAME.equals(evalNode.getFuncDesc().getFunctionName())) {
+    if (NON_CONSTANT_FUNC_NAMES.contains(evalNode.getFuncDesc().getFunctionName())) {
       constantOfAllDescendents = false;
     } else {
       for (EvalNode arg : evalNode.getArgs()) {


Mime
View raw message