Author: hashutosh
Date: Wed Jan 14 01:27:42 2015
New Revision: 1651547

URL: http://svn.apache.org/r1651547
Log:
HIVE-9278 : Cached expression feature broken in one case (Navis via Ashutosh 
Chauhan)

Added:
    hive/branches/branch-0.14/ql/src/test/queries/clientpositive/expr_cached.q
    
hive/branches/branch-0.14/ql/src/test/results/clientpositive/expr_cached.q.out
Modified:
    
hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java

Modified: 
hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java
URL: 
http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java?rev=1651547&r1=1651546&r2=1651547&view=diff
==============================================================================
--- 
hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java
 (original)
+++ 
hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java
 Wed Jan 14 01:27:42 2015
@@ -100,12 +100,14 @@ public final class ExprNodeEvaluatorFact
 
   private static class EvaluatorContext {
 
-    private final Map<String, ExprNodeEvaluator> cached = new HashMap<String, 
ExprNodeEvaluator>();
+    private final Map<ExprNodeDesc.ExprNodeDescEqualityWrapper, 
ExprNodeEvaluator> cached = 
+        new HashMap<ExprNodeDesc.ExprNodeDescEqualityWrapper, 
ExprNodeEvaluator>();
 
     private boolean hasReference;
 
     public ExprNodeEvaluator getEvaluated(ExprNodeEvaluator eval) {
-      String key = eval.getExpr().toString();
+      ExprNodeDesc.ExprNodeDescEqualityWrapper key = 
+          new ExprNodeDesc.ExprNodeDescEqualityWrapper(eval.expr); 
       ExprNodeEvaluator prev = cached.get(key);
       if (prev == null) {
         cached.put(key, eval);

Added: 
hive/branches/branch-0.14/ql/src/test/queries/clientpositive/expr_cached.q
URL: 
http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/expr_cached.q?rev=1651547&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/expr_cached.q 
(added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/expr_cached.q 
Wed Jan 14 01:27:42 2015
@@ -0,0 +1,4 @@
+set hive.fetch.task.conversion=more;
+
+-- should return a value
+select * from src tablesample (1 rows) where length(key) <> reverse(key);
\ No newline at end of file

Added: 
hive/branches/branch-0.14/ql/src/test/results/clientpositive/expr_cached.q.out
URL: 
http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/results/clientpositive/expr_cached.q.out?rev=1651547&view=auto
==============================================================================
--- 
hive/branches/branch-0.14/ql/src/test/results/clientpositive/expr_cached.q.out 
(added)
+++ 
hive/branches/branch-0.14/ql/src/test/results/clientpositive/expr_cached.q.out 
Wed Jan 14 01:27:42 2015
@@ -0,0 +1,11 @@
+PREHOOK: query: -- should return a value
+select * from src tablesample (1 rows) where length(key) <> reverse(key)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: -- should return a value
+select * from src tablesample (1 rows) where length(key) <> reverse(key)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+238    val_238


Reply via email to