You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jd...@apache.org on 2018/04/24 22:51:35 UTC

[3/3] hive git commit: HIVE-19232: results_cache_invalidation2 is failing (Jason Dere, reviewed by Vineet Garg)

HIVE-19232: results_cache_invalidation2 is failing (Jason Dere, reviewed by Vineet Garg)


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

Branch: refs/heads/master
Commit: e909448389c60a8bd13866cbfed98b083be52ba3
Parents: 36ef274
Author: Jason Dere <jd...@hortonworks.com>
Authored: Tue Apr 24 15:51:02 2018 -0700
Committer: Jason Dere <jd...@hortonworks.com>
Committed: Tue Apr 24 15:51:02 2018 -0700

----------------------------------------------------------------------
 .../test/resources/testconfiguration.properties |  16 +-
 .../results_cache_invalidation2.q               |   3 +-
 .../clientpositive/llap/results_cache_2.q.out   | 180 +++++
 .../llap/results_cache_capacity.q.out           | 258 +++++++
 .../llap/results_cache_lifetime.q.out           | 117 +++
 .../llap/results_cache_quoted_identifiers.q.out | 124 +++
 .../llap/results_cache_temptable.q.out          | 323 ++++++++
 .../llap/results_cache_with_masking.q.out       | 116 +++
 .../clientpositive/results_cache_1.q.out        | 579 --------------
 .../clientpositive/results_cache_2.q.out        | 176 -----
 .../clientpositive/results_cache_capacity.q.out | 238 ------
 .../results_cache_empty_result.q.out            |  91 ---
 .../results_cache_invalidation.q.out            | 748 -------------------
 .../results_cache_invalidation2.q.out           | 373 ---------
 .../clientpositive/results_cache_lifetime.q.out | 112 ---
 .../results_cache_quoted_identifiers.q.out      | 116 ---
 .../results_cache_temptable.q.out               | 293 --------
 .../results_cache_transactional.q.out           | 583 ---------------
 .../results_cache_with_masking.q.out            | 106 ---
 19 files changed, 1130 insertions(+), 3422 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/itests/src/test/resources/testconfiguration.properties
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties
index e43c7d4..f32b431 100644
--- a/itests/src/test/resources/testconfiguration.properties
+++ b/itests/src/test/resources/testconfiguration.properties
@@ -216,11 +216,6 @@ minillaplocal.shared.query.files=alter_merge_2_orc.q,\
   ptf.q,\
   ptf_matchpath.q,\
   ptf_streaming.q,\
-  results_cache_1.q,\
-  results_cache_empty_result.q,\
-  results_cache_invalidation.q,\
-  results_cache_transactional.q,\
-  results_cache_invalidation2.q,\
   sample1.q,\
   selectDistinctStar.q,\
   select_dummy_source.q,\
@@ -602,6 +597,17 @@ minillaplocal.query.files=\
   ptf_streaming.q,\
   quotedid_smb.q,\
   resourceplan.q,\
+  results_cache_1.q,\
+  results_cache_2.q,\
+  results_cache_capacity.q,\
+  results_cache_empty_result.q,\
+  results_cache_invalidation.q,\
+  results_cache_invalidation2.q,\
+  results_cache_lifetime.q,\
+  results_cache_quoted_identifiers.q,\
+  results_cache_temptable.q,\
+  results_cache_transactional.q,\
+  results_cache_with_masking.q,\
   sample10.q,\
   schema_evol_orc_acid_part_llap_io.q,\
   schema_evol_orc_acid_part.q,\

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/queries/clientpositive/results_cache_invalidation2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/results_cache_invalidation2.q b/ql/src/test/queries/clientpositive/results_cache_invalidation2.q
index ceee78f..b360c85 100644
--- a/ql/src/test/queries/clientpositive/results_cache_invalidation2.q
+++ b/ql/src/test/queries/clientpositive/results_cache_invalidation2.q
@@ -2,8 +2,7 @@
 set hive.metastore.event.listeners=org.apache.hive.hcatalog.listener.DbNotificationListener;
 
 set hive.query.results.cache.enabled=true;
--- Enable this setting when HIVE-18609 is in
---set hive.query.results.cache.nontransactional.tables.enabled=true;
+set hive.query.results.cache.nontransactional.tables.enabled=true;
 
 set hive.fetch.task.conversion=more;
 -- Start polling the notification events

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/llap/results_cache_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/results_cache_2.q.out b/ql/src/test/results/clientpositive/llap/results_cache_2.q.out
new file mode 100644
index 0000000..0971fc7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/results_cache_2.q.out
@@ -0,0 +1,180 @@
+PREHOOK: query: explain
+select key, value from src where key=0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, value from src where key=0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        TableScan
+          alias: src
+          Filter Operator
+            predicate: (UDFToDouble(key) = 0.0D) (type: boolean)
+            Select Operator
+              expressions: key (type: string), value (type: string)
+              outputColumnNames: _col0, _col1
+              ListSink
+
+PREHOOK: query: select key, value from src where key=0
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select key, value from src where key=0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+0	val_0
+0	val_0
+0	val_0
+test.comment=Query only requires fetch task - should not use results cache
+PREHOOK: query: explain
+select key, value from src where key=0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, value from src where key=0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        TableScan
+          alias: src
+          Filter Operator
+            predicate: (UDFToDouble(key) = 0.0D) (type: boolean)
+            Select Operator
+              expressions: key (type: string), value (type: string)
+              outputColumnNames: _col0, _col1
+              ListSink
+
+PREHOOK: query: select c1, count(*)
+from (select sign(value) c1, value from src where key < 10) q
+group by c1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select c1, count(*)
+from (select sign(value) c1, value from src where key < 10) q
+group by c1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+NULL	10
+test.comment=This query should use the cache
+PREHOOK: query: explain
+select c1, count(*)
+from (select sign(value) c1, value from src where key < 10) q
+group by c1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select c1, count(*)
+from (select sign(value) c1, value from src where key < 10) q
+group by c1
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: select c1, count(*)
+from (select current_timestamp c1, value from src where key < 10) q
+group by c1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select c1, count(*)
+from (select current_timestamp c1, value from src where key < 10) q
+group by c1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+2012-01-01 01:02:03	10
+test.comment=Queries using non-deterministic functions should not use results cache
+PREHOOK: query: explain
+select c1, count(*)
+from (select current_timestamp c1, value from src where key < 10) q
+group by c1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select c1, count(*)
+from (select current_timestamp c1, value from src where key < 10) q
+group by c1
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: src
+                  Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (UDFToDouble(key) < 10.0D) (type: boolean)
+                    Statistics: Num rows: 166 Data size: 14442 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      Statistics: Num rows: 166 Data size: 14442 Basic stats: COMPLETE Column stats: COMPLETE
+                      Group By Operator
+                        aggregations: count()
+                        keys: TIMESTAMP'2012-01-01 01:02:03.0' (type: timestamp)
+                        mode: hash
+                        outputColumnNames: _col0, _col1
+                        Statistics: Num rows: 1 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: timestamp)
+                          sort order: +
+                          Map-reduce partition columns: _col0 (type: timestamp)
+                          Statistics: Num rows: 1 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
+                          value expressions: _col1 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                keys: KEY._col0 (type: timestamp)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 1 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  expressions: TIMESTAMP'2012-01-01 01:02:03.0' (type: timestamp), _col1 (type: bigint)
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 1 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 1 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/llap/results_cache_capacity.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/results_cache_capacity.q.out b/ql/src/test/results/clientpositive/llap/results_cache_capacity.q.out
new file mode 100644
index 0000000..36043f4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/results_cache_capacity.q.out
@@ -0,0 +1,258 @@
+PREHOOK: query: select key, count(*) from src where key = 0 group by key
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select key, count(*) from src where key = 0 group by key
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+0	3
+test.comment=Q1 should be cached
+PREHOOK: query: explain
+select key, count(*) from src where key = 0 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key = 0 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: select key, count(*) from src where key = 2 group by key
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select key, count(*) from src where key = 2 group by key
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+2	1
+test.comment=Q2 should now be cached
+PREHOOK: query: explain
+select key, count(*) from src where key = 2 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key = 2 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+test.comment=Q1 should still be cached
+PREHOOK: query: explain
+select key, count(*) from src where key = 0 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key = 0 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: select key, count(*) from src where key = 4 group by key
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select key, count(*) from src where key = 4 group by key
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+4	1
+test.comment=Q3 should now be cached
+PREHOOK: query: explain
+select key, count(*) from src where key = 4 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key = 4 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+test.comment=Q1 should still be cached
+PREHOOK: query: explain
+select key, count(*) from src where key = 0 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key = 0 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+test.comment=Q2 should no longer be in the cache
+PREHOOK: query: explain
+select key, count(*) from src where key = 2 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key = 2 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: src
+                  Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (UDFToDouble(key) = 2.0D) (type: boolean)
+                    Statistics: Num rows: 250 Data size: 21750 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: count()
+                      keys: key (type: string)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 125 Data size: 11875 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 125 Data size: 11875 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col1 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 125 Data size: 11875 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 125 Data size: 11875 Basic stats: COMPLETE Column stats: COMPLETE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select key, count(*) from src where key < 10 group by key
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select key, count(*) from src where key < 10 group by key
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+8	1
+9	1
+4	1
+2	1
+0	3
+5	3
+PREHOOK: query: explain
+select key, count(*) from src where key < 10 group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from src where key < 10 group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: src
+                  Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (UDFToDouble(key) < 10.0D) (type: boolean)
+                    Statistics: Num rows: 166 Data size: 14442 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: count()
+                      keys: key (type: string)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 83 Data size: 7885 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 83 Data size: 7885 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col1 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                keys: KEY._col0 (type: string)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 83 Data size: 7885 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 83 Data size: 7885 Basic stats: COMPLETE Column stats: COMPLETE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/llap/results_cache_lifetime.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/results_cache_lifetime.q.out b/ql/src/test/results/clientpositive/llap/results_cache_lifetime.q.out
new file mode 100644
index 0000000..69f7aa4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/results_cache_lifetime.q.out
@@ -0,0 +1,117 @@
+PREHOOK: query: select count(*) from src a join src b on (a.key = b.key)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from src a join src b on (a.key = b.key)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+1028
+PREHOOK: query: select reflect("java.lang.Thread", 'sleep', cast(2000 as bigint))
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select reflect("java.lang.Thread", 'sleep', cast(2000 as bigint))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+null
+test.comment="Cached entry should be expired - query should not use cache"
+PREHOOK: query: explain
+select count(*) from src a join src b on (a.key = b.key)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select count(*) from src a join src b on (a.key = b.key)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 4 (SIMPLE_EDGE)
+        Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: a
+                  Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: key is not null (type: boolean)
+                    Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: key (type: string)
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Map 4 
+            Map Operator Tree:
+                TableScan
+                  alias: b
+                  Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: key is not null (type: boolean)
+                    Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: key (type: string)
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: string)
+                        Statistics: Num rows: 500 Data size: 43500 Basic stats: COMPLETE Column stats: COMPLETE
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Merge Join Operator
+                condition map:
+                     Inner Join 0 to 1
+                keys:
+                  0 _col0 (type: string)
+                  1 _col0 (type: string)
+                Statistics: Num rows: 809 Data size: 6472 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count()
+                  mode: hash
+                  outputColumnNames: _col0
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    sort order: 
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: bigint)
+        Reducer 3 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/llap/results_cache_quoted_identifiers.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/results_cache_quoted_identifiers.q.out b/ql/src/test/results/clientpositive/llap/results_cache_quoted_identifiers.q.out
new file mode 100644
index 0000000..7931e1a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/results_cache_quoted_identifiers.q.out
@@ -0,0 +1,124 @@
+PREHOOK: query: create table quoted1 (
+  `_c1` int,
+  `int` int,
+  `col 3` string,
+  `col``4` string
+) stored as textfile
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@quoted1
+POSTHOOK: query: create table quoted1 (
+  `_c1` int,
+  `int` int,
+  `col 3` string,
+  `col``4` string
+) stored as textfile
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@quoted1
+PREHOOK: query: insert into quoted1 select key, key, value, value from src
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: default@quoted1
+POSTHOOK: query: insert into quoted1 select key, key, value, value from src
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: default@quoted1
+POSTHOOK: Lineage: quoted1._c1 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ]
+POSTHOOK: Lineage: quoted1.col 3 SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ]
+POSTHOOK: Lineage: quoted1.col`4 SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ]
+POSTHOOK: Lineage: quoted1.int EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ]
+PREHOOK: query: explain
+select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: quoted1
+                  Statistics: Num rows: 500 Data size: 95000 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    expressions: _c1 (type: int), int (type: int), col 3 (type: string), col`4 (type: string)
+                    outputColumnNames: _c1, int, col 3, col`4
+                    Statistics: Num rows: 500 Data size: 95000 Basic stats: COMPLETE Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: max(_c1), max(int), max(col 3), max(col`4)
+                      mode: hash
+                      outputColumnNames: _col0, _col1, _col2, _col3
+                      Statistics: Num rows: 1 Data size: 376 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        sort order: 
+                        Statistics: Num rows: 1 Data size: 376 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col0 (type: int), _col1 (type: int), _col2 (type: string), _col3 (type: string)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: max(VALUE._col0), max(VALUE._col1), max(VALUE._col2), max(VALUE._col3)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1, _col2, _col3
+                Statistics: Num rows: 1 Data size: 376 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 1 Data size: 376 Basic stats: COMPLETE Column stats: COMPLETE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@quoted1
+#### A masked pattern was here ####
+POSTHOOK: query: select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@quoted1
+#### A masked pattern was here ####
+498	498	val_98	val_98
+test.comment="Cache should be used for this query"
+PREHOOK: query: explain
+select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@quoted1
+POSTHOOK: query: select max(`_c1`), max(`int`), max(`col 3`), max(`col``4`) from quoted1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@quoted1
+498	498	val_98	val_98

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/llap/results_cache_temptable.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/results_cache_temptable.q.out b/ql/src/test/results/clientpositive/llap/results_cache_temptable.q.out
new file mode 100644
index 0000000..d91cae6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/results_cache_temptable.q.out
@@ -0,0 +1,323 @@
+PREHOOK: query: create table rct (key string, value string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rct
+POSTHOOK: query: create table rct (key string, value string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rct
+PREHOOK: query: load data local inpath '../../data/files/kv1.txt' overwrite into table rct
+PREHOOK: type: LOAD
+#### A masked pattern was here ####
+PREHOOK: Output: default@rct
+POSTHOOK: query: load data local inpath '../../data/files/kv1.txt' overwrite into table rct
+POSTHOOK: type: LOAD
+#### A masked pattern was here ####
+POSTHOOK: Output: default@rct
+PREHOOK: query: create table rct_part (key string, value string) partitioned by (ds string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rct_part
+POSTHOOK: query: create table rct_part (key string, value string) partitioned by (ds string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rct_part
+PREHOOK: query: load data local inpath '../../data/files/kv1.txt' overwrite into table rct_part partition (ds="2008-04-08")
+PREHOOK: type: LOAD
+#### A masked pattern was here ####
+PREHOOK: Output: default@rct_part
+POSTHOOK: query: load data local inpath '../../data/files/kv1.txt' overwrite into table rct_part partition (ds="2008-04-08")
+POSTHOOK: type: LOAD
+#### A masked pattern was here ####
+POSTHOOK: Output: default@rct_part
+POSTHOOK: Output: default@rct_part@ds=2008-04-08
+PREHOOK: query: load data local inpath '../../data/files/kv1.txt' overwrite into table rct_part partition (ds="2008-04-09")
+PREHOOK: type: LOAD
+#### A masked pattern was here ####
+PREHOOK: Output: default@rct_part
+POSTHOOK: query: load data local inpath '../../data/files/kv1.txt' overwrite into table rct_part partition (ds="2008-04-09")
+POSTHOOK: type: LOAD
+#### A masked pattern was here ####
+POSTHOOK: Output: default@rct_part
+POSTHOOK: Output: default@rct_part@ds=2008-04-09
+PREHOOK: query: create temporary table tmptab as select * from src
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tmptab
+POSTHOOK: query: create temporary table tmptab as select * from src
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tmptab
+PREHOOK: query: select count(*) from tmptab where key = 0
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tmptab
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from tmptab where key = 0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tmptab
+#### A masked pattern was here ####
+3
+test.comment="Query involving temp tables should not be added to the cache"
+PREHOOK: query: explain
+select count(*) from tmptab where key = 0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select count(*) from tmptab where key = 0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: tmptab
+                  Statistics: Num rows: 500 Data size: 87584 Basic stats: COMPLETE Column stats: NONE
+                  Filter Operator
+                    predicate: (UDFToDouble(key) = 0.0D) (type: boolean)
+                    Statistics: Num rows: 250 Data size: 43792 Basic stats: COMPLETE Column stats: NONE
+                    Select Operator
+                      Statistics: Num rows: 250 Data size: 43792 Basic stats: COMPLETE Column stats: NONE
+                      Group By Operator
+                        aggregations: count()
+                        mode: hash
+                        outputColumnNames: _col0
+                        Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                        Reduce Output Operator
+                          sort order: 
+                          Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                          value expressions: _col0 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select count(*) from rct where key = 0
+PREHOOK: type: QUERY
+PREHOOK: Input: default@rct
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from rct where key = 0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@rct
+#### A masked pattern was here ####
+3
+test.comment="Query should use the cache"
+PREHOOK: query: explain
+select count(*) from rct where key = 0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select count(*) from rct where key = 0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: create temporary table rct as select * from tmptab
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@tmptab
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rct
+POSTHOOK: query: create temporary table rct as select * from tmptab
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@tmptab
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rct
+test.comment="Cached query does not get used now that it resolves to a temp table"
+PREHOOK: query: explain
+select count(*) from rct where key = 0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select count(*) from rct where key = 0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: rct
+                  Statistics: Num rows: 500 Data size: 87584 Basic stats: COMPLETE Column stats: NONE
+                  Filter Operator
+                    predicate: (UDFToDouble(key) = 0.0D) (type: boolean)
+                    Statistics: Num rows: 250 Data size: 43792 Basic stats: COMPLETE Column stats: NONE
+                    Select Operator
+                      Statistics: Num rows: 250 Data size: 43792 Basic stats: COMPLETE Column stats: NONE
+                      Group By Operator
+                        aggregations: count()
+                        mode: hash
+                        outputColumnNames: _col0
+                        Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                        Reduce Output Operator
+                          sort order: 
+                          Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                          value expressions: _col0 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select count(*) from rct_part where ds="2008-04-08" and key = 0
+PREHOOK: type: QUERY
+PREHOOK: Input: default@rct_part
+PREHOOK: Input: default@rct_part@ds=2008-04-08
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from rct_part where ds="2008-04-08" and key = 0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@rct_part
+POSTHOOK: Input: default@rct_part@ds=2008-04-08
+#### A masked pattern was here ####
+3
+test.comment="Query should use the cache"
+PREHOOK: query: explain
+select count(*) from rct_part where ds="2008-04-08" and key = 0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select count(*) from rct_part where ds="2008-04-08" and key = 0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: create temporary table rct_part as select key, value, "2008-04-08" as ds from tmptab
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@tmptab
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rct_part
+POSTHOOK: query: create temporary table rct_part as select key, value, "2008-04-08" as ds from tmptab
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@tmptab
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rct_part
+test.comment="Cached query does not get used now that it resolves to a temp table"
+PREHOOK: query: explain
+select count(*) from rct_part where ds="2008-04-08" and key = 0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select count(*) from rct_part where ds="2008-04-08" and key = 0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: rct_part
+                  Statistics: Num rows: 500 Data size: 175168 Basic stats: COMPLETE Column stats: NONE
+                  Filter Operator
+                    predicate: ((UDFToDouble(key) = 0.0D) and (ds = '2008-04-08')) (type: boolean)
+                    Statistics: Num rows: 2 Data size: 700 Basic stats: COMPLETE Column stats: NONE
+                    Select Operator
+                      Statistics: Num rows: 2 Data size: 700 Basic stats: COMPLETE Column stats: NONE
+                      Group By Operator
+                        aggregations: count()
+                        mode: hash
+                        outputColumnNames: _col0
+                        Statistics: Num rows: 1 Data size: 9223372036854775807 Basic stats: COMPLETE Column stats: NONE
+                        Reduce Output Operator
+                          sort order: 
+                          Statistics: Num rows: 1 Data size: 9223372036854775807 Basic stats: COMPLETE Column stats: NONE
+                          value expressions: _col0 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 9223372036854775807 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 1 Data size: 9223372036854775807 Basic stats: COMPLETE Column stats: NONE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/llap/results_cache_with_masking.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/results_cache_with_masking.q.out b/ql/src/test/results/clientpositive/llap/results_cache_with_masking.q.out
new file mode 100644
index 0000000..d2d8275
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/results_cache_with_masking.q.out
@@ -0,0 +1,116 @@
+PREHOOK: query: create table masking_test as select cast(key as int) as key, value from src
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+PREHOOK: Output: database:default
+PREHOOK: Output: default@masking_test
+POSTHOOK: query: create table masking_test as select cast(key as int) as key, value from src
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@masking_test
+POSTHOOK: Lineage: masking_test.key EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ]
+POSTHOOK: Lineage: masking_test.value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ]
+PREHOOK: query: explain
+select key, count(*) from masking_test group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from masking_test group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: masking_test
+                  Statistics: Num rows: 500 Data size: 1904 Basic stats: COMPLETE Column stats: NONE
+                  Filter Operator
+                    predicate: (((key % 2) = 0) and (key < 10)) (type: boolean)
+                    Statistics: Num rows: 250 Data size: 952 Basic stats: COMPLETE Column stats: NONE
+                    Group By Operator
+                      aggregations: count()
+                      keys: key (type: int)
+                      mode: hash
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 250 Data size: 952 Basic stats: COMPLETE Column stats: NONE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: int)
+                        sort order: +
+                        Map-reduce partition columns: _col0 (type: int)
+                        Statistics: Num rows: 250 Data size: 952 Basic stats: COMPLETE Column stats: NONE
+                        value expressions: _col1 (type: bigint)
+            Execution mode: llap
+            LLAP IO: no inputs
+        Reducer 2 
+            Execution mode: llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                keys: KEY._col0 (type: int)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 125 Data size: 476 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 125 Data size: 476 Basic stats: COMPLETE Column stats: NONE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select key, count(*) from masking_test group by key
+PREHOOK: type: QUERY
+PREHOOK: Input: default@masking_test
+#### A masked pattern was here ####
+POSTHOOK: query: select key, count(*) from masking_test group by key
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@masking_test
+#### A masked pattern was here ####
+4	1
+0	3
+2	1
+8	1
+PREHOOK: query: explain
+select key, count(*) from masking_test group by key
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select key, count(*) from masking_test group by key
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+      Cached Query Result: true
+
+PREHOOK: query: select key, count(*) from masking_test group by key
+PREHOOK: type: QUERY
+PREHOOK: Input: default@masking_test
+#### A masked pattern was here ####
+POSTHOOK: query: select key, count(*) from masking_test group by key
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@masking_test
+#### A masked pattern was here ####
+4	1
+0	3
+2	1
+8	1

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/results_cache_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/results_cache_1.q.out b/ql/src/test/results/clientpositive/results_cache_1.q.out
deleted file mode 100644
index e3359d4..0000000
--- a/ql/src/test/results/clientpositive/results_cache_1.q.out
+++ /dev/null
@@ -1,579 +0,0 @@
-PREHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1
-  Stage-0 depends on stages: Stage-2
-
-STAGE PLANS:
-  Stage: Stage-1
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: a
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: key is not null (type: boolean)
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                expressions: key (type: string)
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-          TableScan
-            alias: b
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: key is not null (type: boolean)
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                expressions: key (type: string)
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: string)
-            1 _col0 (type: string)
-          Statistics: Num rows: 550 Data size: 5843 Basic stats: COMPLETE Column stats: NONE
-          Group By Operator
-            aggregations: count()
-            mode: hash
-            outputColumnNames: _col0
-            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-
-  Stage: Stage-2
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              sort order: 
-              Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-              value expressions: _col0 (type: bigint)
-      Reduce Operator Tree:
-        Group By Operator
-          aggregations: count(VALUE._col0)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
-
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-
-PREHOOK: query: select count(*) from src a join src b on (a.key = b.key)
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select count(*) from src a join src b on (a.key = b.key)
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-1028
-test.comment="Cache should be used for this query"
-PREHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-      Cached Query Result: true
-
-PREHOOK: query: select count(*) from src a join src b on (a.key = b.key)
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select count(*) from src a join src b on (a.key = b.key)
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-1028
-test.comment="Cache is disabled, should not be used here."
-PREHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1
-  Stage-0 depends on stages: Stage-2
-
-STAGE PLANS:
-  Stage: Stage-1
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: a
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: key is not null (type: boolean)
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                expressions: key (type: string)
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-          TableScan
-            alias: b
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: key is not null (type: boolean)
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                expressions: key (type: string)
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: string)
-            1 _col0 (type: string)
-          Statistics: Num rows: 550 Data size: 5843 Basic stats: COMPLETE Column stats: NONE
-          Group By Operator
-            aggregations: count()
-            mode: hash
-            outputColumnNames: _col0
-            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-
-  Stage: Stage-2
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              sort order: 
-              Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-              value expressions: _col0 (type: bigint)
-      Reduce Operator Tree:
-        Group By Operator
-          aggregations: count(VALUE._col0)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
-
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-
-PREHOOK: query: create database db1
-PREHOOK: type: CREATEDATABASE
-PREHOOK: Output: database:db1
-POSTHOOK: query: create database db1
-POSTHOOK: type: CREATEDATABASE
-POSTHOOK: Output: database:db1
-PREHOOK: query: use db1
-PREHOOK: type: SWITCHDATABASE
-PREHOOK: Input: database:db1
-POSTHOOK: query: use db1
-POSTHOOK: type: SWITCHDATABASE
-POSTHOOK: Input: database:db1
-PREHOOK: query: create table src as select key, value from default.src
-PREHOOK: type: CREATETABLE_AS_SELECT
-PREHOOK: Input: default@src
-PREHOOK: Output: database:db1
-PREHOOK: Output: db1@src
-POSTHOOK: query: create table src as select key, value from default.src
-POSTHOOK: type: CREATETABLE_AS_SELECT
-POSTHOOK: Input: default@src
-POSTHOOK: Output: database:db1
-POSTHOOK: Output: db1@src
-POSTHOOK: Lineage: src.key SIMPLE [(src)src.FieldSchema(name:key, type:string, comment:default), ]
-POSTHOOK: Lineage: src.value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ]
-test.comment="Same query string, but different current database. Cache should not be used since unqualified tablenames resolve to different tables"
-PREHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select count(*) from src a join src b on (a.key = b.key)
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1
-  Stage-0 depends on stages: Stage-2
-
-STAGE PLANS:
-  Stage: Stage-1
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: a
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: key is not null (type: boolean)
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                expressions: key (type: string)
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-          TableScan
-            alias: b
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: key is not null (type: boolean)
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                expressions: key (type: string)
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: string)
-            1 _col0 (type: string)
-          Statistics: Num rows: 550 Data size: 5843 Basic stats: COMPLETE Column stats: NONE
-          Group By Operator
-            aggregations: count()
-            mode: hash
-            outputColumnNames: _col0
-            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-
-  Stage: Stage-2
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              sort order: 
-              Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-              value expressions: _col0 (type: bigint)
-      Reduce Operator Tree:
-        Group By Operator
-          aggregations: count(VALUE._col0)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-          File Output Operator
-            compressed: false
-            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
-            table:
-                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
-
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-
-PREHOOK: query: use default
-PREHOOK: type: SWITCHDATABASE
-PREHOOK: Input: database:default
-POSTHOOK: query: use default
-POSTHOOK: type: SWITCHDATABASE
-POSTHOOK: Input: database:default
-PREHOOK: query: select * from src where key = 0
-union all
-select * from src where key = 2
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select * from src where key = 0
-union all
-select * from src where key = 2
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-0	val_0
-0	val_0
-0	val_0
-2	val_2
-test.comment="Union all. Cache should be used now"
-PREHOOK: query: explain
-select * from src where key = 0
-union all
-select * from src where key = 2
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select * from src where key = 0
-union all
-select * from src where key = 2
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-      Cached Query Result: true
-
-PREHOOK: query: select * from src where key = 0
-union all
-select * from src where key = 2
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select * from src where key = 0
-union all
-select * from src where key = 2
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-0	val_0
-0	val_0
-0	val_0
-2	val_2
-PREHOOK: query: with q1 as ( select distinct key from q2 ),
-q2 as ( select key, value from src where key < 10 )
-select * from q1 a, q1 b where a.key = b.key
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: with q1 as ( select distinct key from q2 ),
-q2 as ( select key, value from src where key < 10 )
-select * from q1 a, q1 b where a.key = b.key
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-0	0
-2	2
-4	4
-5	5
-8	8
-9	9
-test.comment="CTE. Cache should be used now"
-PREHOOK: query: explain
-with q1 as ( select distinct key from q2 ),
-q2 as ( select key, value from src where key < 10 )
-select * from q1 a, q1 b where a.key = b.key
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-with q1 as ( select distinct key from q2 ),
-q2 as ( select key, value from src where key < 10 )
-select * from q1 a, q1 b where a.key = b.key
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-      Cached Query Result: true
-
-PREHOOK: query: with q1 as ( select distinct key from q2 ),
-q2 as ( select key, value from src where key < 10 )
-select * from q1 a, q1 b where a.key = b.key
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: with q1 as ( select distinct key from q2 ),
-q2 as ( select key, value from src where key < 10 )
-select * from q1 a, q1 b where a.key = b.key
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-0	0
-2	2
-4	4
-5	5
-8	8
-9	9
-PREHOOK: query: with q1 as ( select distinct key, value from src ),
-q2 as ( select key, value from src where key < 10 ),
-q3 as ( select key, value from src where key = 0 )
-select * from q1 intersect all select * from q2 except all select * from q3
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: with q1 as ( select distinct key, value from src ),
-q2 as ( select key, value from src where key < 10 ),
-q3 as ( select key, value from src where key = 0 )
-select * from q1 intersect all select * from q2 except all select * from q3
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-2	val_2
-4	val_4
-5	val_5
-8	val_8
-9	val_9
-test.comment="Intersect/Except. Cache should be used now"
-PREHOOK: query: explain
-with q1 as ( select distinct key, value from src ),
-q2 as ( select key, value from src where key < 10 ),
-q3 as ( select key, value from src where key = 0 )
-select * from q1 intersect all select * from q2 except all select * from q3
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-with q1 as ( select distinct key, value from src ),
-q2 as ( select key, value from src where key < 10 ),
-q3 as ( select key, value from src where key = 0 )
-select * from q1 intersect all select * from q2 except all select * from q3
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-      Cached Query Result: true
-
-PREHOOK: query: with q1 as ( select distinct key, value from src ),
-q2 as ( select key, value from src where key < 10 ),
-q3 as ( select key, value from src where key = 0 )
-select * from q1 intersect all select * from q2 except all select * from q3
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: with q1 as ( select distinct key, value from src ),
-q2 as ( select key, value from src where key < 10 ),
-q3 as ( select key, value from src where key = 0 )
-select * from q1 intersect all select * from q2 except all select * from q3
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-2	val_2
-4	val_4
-5	val_5
-8	val_8
-9	val_9
-PREHOOK: query: select a, c, count(*)  from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by a+b desc, c asc limit 5) cbo_t1 left semi join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by q+r/10 desc, p limit 5) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1  >= 0) and (b > 0 or a >= 0) group by a, c  having a > 0 and (a >=1 or c >= 1) and (a + c) >= 0 order by c, a
-PREHOOK: type: QUERY
-PREHOOK: Input: default@cbo_t1
-PREHOOK: Input: default@cbo_t1@dt=2014
-PREHOOK: Input: default@cbo_t2
-PREHOOK: Input: default@cbo_t2@dt=2014
-PREHOOK: Input: default@cbo_t3
-#### A masked pattern was here ####
-POSTHOOK: query: select a, c, count(*)  from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by a+b desc, c asc limit 5) cbo_t1 left semi join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by q+r/10 desc, p limit 5) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1  >= 0) and (b > 0 or a >= 0) group by a, c  having a > 0 and (a >=1 or c >= 1) and (a + c) >= 0 order by c, a
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@cbo_t1
-POSTHOOK: Input: default@cbo_t1@dt=2014
-POSTHOOK: Input: default@cbo_t2
-POSTHOOK: Input: default@cbo_t2@dt=2014
-POSTHOOK: Input: default@cbo_t3
-#### A masked pattern was here ####
- 1	2	1
- 1 	2	1
-1 	2	1
-1	12	1
-test.comment="Semijoin. Cache should be used now"
-PREHOOK: query: explain
-select a, c, count(*)  from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by a+b desc, c asc limit 5) cbo_t1 left semi join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by q+r/10 desc, p limit 5) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1  >= 0) and (b > 0 or a >= 0) group by a, c  having a > 0 and (a >=1 or c >= 1) and (a + c) >= 0 order by c, a
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select a, c, count(*)  from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by a+b desc, c asc limit 5) cbo_t1 left semi join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by q+r/10 desc, p limit 5) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1  >= 0) and (b > 0 or a >= 0) group by a, c  having a > 0 and (a >=1 or c >= 1) and (a + c) >= 0 order by c, a
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-      Cached Query Result: true
-
-PREHOOK: query: select a, c, count(*)  from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by a+b desc, c asc limit 5) cbo_t1 left semi join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by q+r/10 desc, p limit 5) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1  >= 0) and (b > 0 or a >= 0) group by a, c  having a > 0 and (a >=1 or c >= 1) and (a + c) >= 0 order by c, a
-PREHOOK: type: QUERY
-PREHOOK: Input: default@cbo_t1
-PREHOOK: Input: default@cbo_t1@dt=2014
-PREHOOK: Input: default@cbo_t2
-PREHOOK: Input: default@cbo_t2@dt=2014
-PREHOOK: Input: default@cbo_t3
-#### A masked pattern was here ####
-POSTHOOK: query: select a, c, count(*)  from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by a+b desc, c asc limit 5) cbo_t1 left semi join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by q+r/10 desc, p limit 5) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1  >= 0) and (b > 0 or a >= 0) group by a, c  having a > 0 and (a >=1 or c >= 1) and (a + c) >= 0 order by c, a
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@cbo_t1
-POSTHOOK: Input: default@cbo_t1@dt=2014
-POSTHOOK: Input: default@cbo_t2
-POSTHOOK: Input: default@cbo_t2@dt=2014
-POSTHOOK: Input: default@cbo_t3
-#### A masked pattern was here ####
- 1	2	1
- 1 	2	1
-1 	2	1
-1	12	1

http://git-wip-us.apache.org/repos/asf/hive/blob/e9094483/ql/src/test/results/clientpositive/results_cache_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/results_cache_2.q.out b/ql/src/test/results/clientpositive/results_cache_2.q.out
deleted file mode 100644
index 40dd71d..0000000
--- a/ql/src/test/results/clientpositive/results_cache_2.q.out
+++ /dev/null
@@ -1,176 +0,0 @@
-PREHOOK: query: explain
-select key, value from src where key=0
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select key, value from src where key=0
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        TableScan
-          alias: src
-          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-          Filter Operator
-            predicate: (UDFToDouble(key) = 0.0D) (type: boolean)
-            Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE Column stats: NONE
-            Select Operator
-              expressions: key (type: string), value (type: string)
-              outputColumnNames: _col0, _col1
-              Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE Column stats: NONE
-              ListSink
-
-PREHOOK: query: select key, value from src where key=0
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select key, value from src where key=0
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-0	val_0
-0	val_0
-0	val_0
-test.comment=Query only requires fetch task - should not use results cache
-PREHOOK: query: explain
-select key, value from src where key=0
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select key, value from src where key=0
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        TableScan
-          alias: src
-          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-          Filter Operator
-            predicate: (UDFToDouble(key) = 0.0D) (type: boolean)
-            Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE Column stats: NONE
-            Select Operator
-              expressions: key (type: string), value (type: string)
-              outputColumnNames: _col0, _col1
-              Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE Column stats: NONE
-              ListSink
-
-PREHOOK: query: select c1, count(*)
-from (select sign(value) c1, value from src where key < 10) q
-group by c1
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select c1, count(*)
-from (select sign(value) c1, value from src where key < 10) q
-group by c1
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-NULL	10
-test.comment=This query should use the cache
-PREHOOK: query: explain
-select c1, count(*)
-from (select sign(value) c1, value from src where key < 10) q
-group by c1
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select c1, count(*)
-from (select sign(value) c1, value from src where key < 10) q
-group by c1
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-0 is a root stage
-
-STAGE PLANS:
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-      Cached Query Result: true
-
-PREHOOK: query: select c1, count(*)
-from (select current_timestamp c1, value from src where key < 10) q
-group by c1
-PREHOOK: type: QUERY
-PREHOOK: Input: default@src
-#### A masked pattern was here ####
-POSTHOOK: query: select c1, count(*)
-from (select current_timestamp c1, value from src where key < 10) q
-group by c1
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@src
-#### A masked pattern was here ####
-2012-01-01 01:02:03	10
-test.comment=Queries using non-deterministic functions should not use results cache
-PREHOOK: query: explain
-select c1, count(*)
-from (select current_timestamp c1, value from src where key < 10) q
-group by c1
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select c1, count(*)
-from (select current_timestamp c1, value from src where key < 10) q
-group by c1
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-1 is a root stage
-  Stage-0 depends on stages: Stage-1
-
-STAGE PLANS:
-  Stage: Stage-1
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: src
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-            Filter Operator
-              predicate: (UDFToDouble(key) < 10.0D) (type: boolean)
-              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
-              Select Operator
-                Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
-                Group By Operator
-                  aggregations: count()
-                  keys: TIMESTAMP'2012-01-01 01:02:03.0' (type: timestamp)
-                  mode: hash
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: timestamp)
-                    sort order: +
-                    Map-reduce partition columns: _col0 (type: timestamp)
-                    Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col1 (type: bigint)
-      Reduce Operator Tree:
-        Group By Operator
-          aggregations: count(VALUE._col0)
-          keys: KEY._col0 (type: timestamp)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE Column stats: NONE
-          Select Operator
-            expressions: TIMESTAMP'2012-01-01 01:02:03.0' (type: timestamp), _col1 (type: bigint)
-            outputColumnNames: _col0, _col1
-            Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
-              Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE Column stats: NONE
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
-
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-