You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2014/11/06 19:59:40 UTC

svn commit: r1637182 [1/14] - in /hive/trunk: ./ data/scripts/ itests/src/test/resources/ ql/src/test/queries/clientnegative/ ql/src/test/queries/clientpositive/ ql/src/test/results/clientnegative/ ql/src/test/results/clientpositive/ ql/src/test/result...

Author: hashutosh
Date: Thu Nov  6 18:59:36 2014
New Revision: 1637182

URL: http://svn.apache.org/r1637182
Log:
HIVE-8636 : CBO: split cbo_correctness test (Sergey Shelukhin via Ashutosh Chauhan)

Added:
    hive/trunk/ql/src/test/queries/clientpositive/cbo_gby.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_gby_empty.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_join.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_limit.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_semijoin.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_simple_select.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_stats.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_exists.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_in.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_not_in.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_udf_udaf.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_views.q
    hive/trunk/ql/src/test/queries/clientpositive/cbo_windowing.q
    hive/trunk/ql/src/test/results/clientpositive/cbo_gby.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_gby_empty.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_join.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_limit.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_semijoin.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_simple_select.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_stats.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_subq_exists.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_subq_in.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_subq_not_in.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_udf_udaf.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_union.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_views.q.out
    hive/trunk/ql/src/test/results/clientpositive/cbo_windowing.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_gby.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_gby_empty.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_join.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_limit.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_semijoin.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_simple_select.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_stats.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_subq_exists.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_subq_in.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_subq_not_in.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_udf_udaf.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_union.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_views.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_windowing.q.out
Removed:
    hive/trunk/ql/src/test/queries/clientpositive/cbo_correctness.q
    hive/trunk/ql/src/test/results/clientpositive/cbo_correctness.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/cbo_correctness.q.out
Modified:
    hive/trunk/data/scripts/q_test_cleanup.sql
    hive/trunk/data/scripts/q_test_init.sql
    hive/trunk/itests/src/test/resources/testconfiguration.properties
    hive/trunk/pom.xml
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DistributeByOrderBy.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithPTF.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_JoinWithAmbigousAlias.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_PartitionBySortBy.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_WhereWithRankCond.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries.q
    hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries2.q
    hive/trunk/ql/src/test/queries/clientnegative/subquery_nested_subquery.q
    hive/trunk/ql/src/test/queries/clientnegative/subquery_windowing_corr.q
    hive/trunk/ql/src/test/queries/clientnegative/windowing_leadlag_in_udaf.q
    hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_neg.q
    hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_over.q
    hive/trunk/ql/src/test/queries/clientpositive/join_alt_syntax.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_1.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_2.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_3.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_4.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual1.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual2.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual3.q
    hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual4.q
    hive/trunk/ql/src/test/queries/clientpositive/join_merging.q
    hive/trunk/ql/src/test/queries/clientpositive/leadlag.q
    hive/trunk/ql/src/test/queries/clientpositive/leadlag_queries.q
    hive/trunk/ql/src/test/queries/clientpositive/order_within_subquery.q
    hive/trunk/ql/src/test/queries/clientpositive/ptf.q
    hive/trunk/ql/src/test/queries/clientpositive/ptf_decimal.q
    hive/trunk/ql/src/test/queries/clientpositive/ptf_general_queries.q
    hive/trunk/ql/src/test/queries/clientpositive/ptf_streaming.q
    hive/trunk/ql/src/test/queries/clientpositive/ql_rewrite_gbtoidx.q
    hive/trunk/ql/src/test/queries/clientpositive/reducesink_dedup.q
    hive/trunk/ql/src/test/queries/clientpositive/subquery_in.q
    hive/trunk/ql/src/test/queries/clientpositive/subquery_in_explain_rewrite.q
    hive/trunk/ql/src/test/queries/clientpositive/subquery_in_having.q
    hive/trunk/ql/src/test/queries/clientpositive/subquery_notin.q
    hive/trunk/ql/src/test/queries/clientpositive/subquery_notin_having.q
    hive/trunk/ql/src/test/queries/clientpositive/subquery_unqualcolumnrefs.q
    hive/trunk/ql/src/test/queries/clientpositive/temp_table_windowing_expressions.q
    hive/trunk/ql/src/test/queries/clientpositive/vector_mapjoin_reduce.q
    hive/trunk/ql/src/test/queries/clientpositive/vectorized_ptf.q
    hive/trunk/ql/src/test/queries/clientpositive/windowing.q
    hive/trunk/ql/src/test/queries/clientpositive/windowing_adjust_rowcontainer_sz.q
    hive/trunk/ql/src/test/queries/clientpositive/windowing_columnPruning.q
    hive/trunk/ql/src/test/queries/clientpositive/windowing_decimal.q
    hive/trunk/ql/src/test/queries/clientpositive/windowing_expressions.q
    hive/trunk/ql/src/test/queries/clientpositive/windowing_streaming.q
    hive/trunk/ql/src/test/results/clientnegative/limit_partition_stats.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_AmbiguousWindowDefn.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_DistributeByOrderBy.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_DuplicateWindowAlias.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_HavingLeadWithPTF.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_InvalidValueBoundary.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_JoinWithAmbigousAlias.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_PartitionBySortBy.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_negative_WhereWithRankCond.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_window_boundaries.q.out
    hive/trunk/ql/src/test/results/clientnegative/ptf_window_boundaries2.q.out
    hive/trunk/ql/src/test/results/clientnegative/subquery_nested_subquery.q.out
    hive/trunk/ql/src/test/results/clientnegative/subquery_windowing_corr.q.out
    hive/trunk/ql/src/test/results/clientnegative/windowing_leadlag_in_udaf.q.out
    hive/trunk/ql/src/test/results/clientnegative/windowing_ll_no_neg.q.out
    hive/trunk/ql/src/test/results/clientnegative/windowing_ll_no_over.q.out
    hive/trunk/ql/src/test/results/clientpositive/add_part_exist.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter1.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter2.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter3.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter4.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter5.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter_index.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter_rename_partition.q.out
    hive/trunk/ql/src/test/results/clientpositive/describe_table_json.q.out
    hive/trunk/ql/src/test/results/clientpositive/index_creation.q.out
    hive/trunk/ql/src/test/results/clientpositive/input2.q.out
    hive/trunk/ql/src/test/results/clientpositive/input3.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_alt_syntax.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_1.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_2.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_3.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_4.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_unqual1.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_unqual2.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_unqual3.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_cond_pushdown_unqual4.q.out
    hive/trunk/ql/src/test/results/clientpositive/join_merging.q.out
    hive/trunk/ql/src/test/results/clientpositive/leadlag.q.out
    hive/trunk/ql/src/test/results/clientpositive/leadlag_queries.q.out
    hive/trunk/ql/src/test/results/clientpositive/order_within_subquery.q.out
    hive/trunk/ql/src/test/results/clientpositive/ptf.q.out
    hive/trunk/ql/src/test/results/clientpositive/ptf_decimal.q.out
    hive/trunk/ql/src/test/results/clientpositive/ptf_general_queries.q.out
    hive/trunk/ql/src/test/results/clientpositive/ptf_streaming.q.out
    hive/trunk/ql/src/test/results/clientpositive/ql_rewrite_gbtoidx.q.out
    hive/trunk/ql/src/test/results/clientpositive/reducesink_dedup.q.out
    hive/trunk/ql/src/test/results/clientpositive/rename_column.q.out
    hive/trunk/ql/src/test/results/clientpositive/show_tables.q.out
    hive/trunk/ql/src/test/results/clientpositive/subquery_in.q.out
    hive/trunk/ql/src/test/results/clientpositive/subquery_in_explain_rewrite.q.out
    hive/trunk/ql/src/test/results/clientpositive/subquery_in_having.q.out
    hive/trunk/ql/src/test/results/clientpositive/subquery_notin.q.out
    hive/trunk/ql/src/test/results/clientpositive/subquery_notin_having.q.out
    hive/trunk/ql/src/test/results/clientpositive/subquery_unqualcolumnrefs.q.out
    hive/trunk/ql/src/test/results/clientpositive/temp_table.q.out
    hive/trunk/ql/src/test/results/clientpositive/temp_table_windowing_expressions.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/ptf.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/subquery_in.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/temp_table.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/vector_mapjoin_reduce.q.out
    hive/trunk/ql/src/test/results/clientpositive/tez/vectorized_ptf.q.out
    hive/trunk/ql/src/test/results/clientpositive/vector_mapjoin_reduce.q.out
    hive/trunk/ql/src/test/results/clientpositive/vectorized_ptf.q.out
    hive/trunk/ql/src/test/results/clientpositive/windowing.q.out
    hive/trunk/ql/src/test/results/clientpositive/windowing_adjust_rowcontainer_sz.q.out
    hive/trunk/ql/src/test/results/clientpositive/windowing_columnPruning.q.out
    hive/trunk/ql/src/test/results/clientpositive/windowing_decimal.q.out
    hive/trunk/ql/src/test/results/clientpositive/windowing_expressions.q.out
    hive/trunk/ql/src/test/results/clientpositive/windowing_streaming.q.out

Modified: hive/trunk/data/scripts/q_test_cleanup.sql
URL: http://svn.apache.org/viewvc/hive/trunk/data/scripts/q_test_cleanup.sql?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/data/scripts/q_test_cleanup.sql (original)
+++ hive/trunk/data/scripts/q_test_cleanup.sql Thu Nov  6 18:59:36 2014
@@ -16,3 +16,10 @@ DROP TABLE IF EXISTS dest_j1;
 DROP TABLE IF EXISTS dest_g1;
 DROP TABLE IF EXISTS dest_g2;
 DROP TABLE IF EXISTS fetchtask_ioexception;
+
+DROP TABLE IF EXISTS cbo_t1;
+DROP TABLE IF EXISTS cbo_t2;
+DROP TABLE IF EXISTS cbo_t3;
+DROP TABLE IF EXISTS src_cbo;
+DROP TABLE IF EXISTS part;
+DROP TABLE IF EXISTS lineitem;

Modified: hive/trunk/data/scripts/q_test_init.sql
URL: http://svn.apache.org/viewvc/hive/trunk/data/scripts/q_test_init.sql?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/data/scripts/q_test_init.sql (original)
+++ hive/trunk/data/scripts/q_test_init.sql Thu Nov  6 18:59:36 2014
@@ -243,3 +243,79 @@ CREATE TABLE dest4_sequencefile (key STR
 STORED AS
 INPUTFORMAT 'org.apache.hadoop.mapred.SequenceFileInputFormat'
 OUTPUTFORMAT 'org.apache.hadoop.mapred.SequenceFileOutputFormat';
+
+
+--
+-- CBO tables
+--
+
+drop table if exists cbo_t1;
+drop table if exists cbo_t2;
+drop table if exists cbo_t3;
+drop table if exists src_cbo;
+drop table if exists part;
+drop table if exists lineitem;
+
+set hive.cbo.enable=true;
+
+create table cbo_t1(key string, value string, c_int int, c_float float, c_boolean boolean)  partitioned by (dt string) row format delimited fields terminated by ',' STORED AS TEXTFILE;
+create table cbo_t2(key string, value string, c_int int, c_float float, c_boolean boolean)  partitioned by (dt string) row format delimited fields terminated by ',' STORED AS TEXTFILE;
+create table cbo_t3(key string, value string, c_int int, c_float float, c_boolean boolean)  row format delimited fields terminated by ',' STORED AS TEXTFILE;
+
+load data local inpath '../../data/files/cbo_t1.txt' into table cbo_t1 partition (dt='2014');
+load data local inpath '../../data/files/cbo_t2.txt' into table cbo_t2 partition (dt='2014');
+load data local inpath '../../data/files/cbo_t3.txt' into table cbo_t3;
+
+CREATE TABLE part(
+    p_partkey INT,
+    p_name STRING,
+    p_mfgr STRING,
+    p_brand STRING,
+    p_type STRING,
+    p_size INT,
+    p_container STRING,
+    p_retailprice DOUBLE,
+    p_comment STRING
+);
+
+LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
+
+CREATE TABLE lineitem (L_ORDERKEY      INT,
+                                L_PARTKEY       INT,
+                                L_SUPPKEY       INT,
+                                L_LINENUMBER    INT,
+                                L_QUANTITY      DOUBLE,
+                                L_EXTENDEDPRICE DOUBLE,
+                                L_DISCOUNT      DOUBLE,
+                                L_TAX           DOUBLE,
+                                L_RETURNFLAG    STRING,
+                                L_LINESTATUS    STRING,
+                                l_shipdate      STRING,
+                                L_COMMITDATE    STRING,
+                                L_RECEIPTDATE   STRING,
+                                L_SHIPINSTRUCT  STRING,
+                                L_SHIPMODE      STRING,
+                                L_COMMENT       STRING)
+ROW FORMAT DELIMITED
+FIELDS TERMINATED BY '|';
+
+LOAD DATA LOCAL INPATH '../../data/files/lineitem.txt' OVERWRITE INTO TABLE lineitem;
+
+create table src_cbo as select * from src;
+
+
+analyze table cbo_t1 partition (dt) compute statistics;
+analyze table cbo_t1 compute statistics for columns key, value, c_int, c_float, c_boolean;
+analyze table cbo_t2 partition (dt) compute statistics;
+analyze table cbo_t2 compute statistics for columns key, value, c_int, c_float, c_boolean;
+analyze table cbo_t3 compute statistics;
+analyze table cbo_t3 compute statistics for columns key, value, c_int, c_float, c_boolean;
+analyze table src_cbo compute statistics;
+analyze table src_cbo compute statistics for columns;
+analyze table part compute statistics;
+analyze table part compute statistics for columns;
+analyze table lineitem compute statistics;
+analyze table lineitem compute statistics for columns;
+
+reset;
+set hive.stats.dbclass=fs;

Modified: hive/trunk/itests/src/test/resources/testconfiguration.properties
URL: http://svn.apache.org/viewvc/hive/trunk/itests/src/test/resources/testconfiguration.properties?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/itests/src/test/resources/testconfiguration.properties (original)
+++ hive/trunk/itests/src/test/resources/testconfiguration.properties Thu Nov  6 18:59:36 2014
@@ -55,7 +55,20 @@ minitez.query.files.shared=alter_merge_2
   bucket2.q,\
   bucket3.q,\
   bucket4.q,\
-  cbo_correctness.q,\
+  cbo_gby.q,\
+  cbo_gby_empty.q,\
+  cbo_join.q,\
+  cbo_limit.q,\
+  cbo_semijoin.q,\
+  cbo_simple_select.q,\
+  cbo_stats.q,\
+  cbo_subq_exists.q,\
+  cbo_subq_in.q,\
+  cbo_subq_not_in.q,\
+  cbo_udf_udaf.q,\
+  cbo_union.q,\
+  cbo_views.q,\
+  cbo_windowing.q,\
   correlationoptimizer1.q,\
   count.q,\
   create_merge_compressed.q,\

Modified: hive/trunk/pom.xml
URL: http://svn.apache.org/viewvc/hive/trunk/pom.xml?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/pom.xml (original)
+++ hive/trunk/pom.xml Thu Nov  6 18:59:36 2014
@@ -829,7 +829,7 @@
             <test.warehouse.dir>${test.warehouse.scheme}${test.warehouse.dir}</test.warehouse.dir>
             <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
             <!-- EnforceReadOnlyTables hook and QTestUtil -->
-            <test.src.tables>src,src1,srcbucket,srcbucket2,src_json,src_thrift,src_sequencefile,srcpart,alltypesorc,src_hbase</test.src.tables>
+            <test.src.tables>src,src1,srcbucket,srcbucket2,src_json,src_thrift,src_sequencefile,srcpart,alltypesorc,src_hbase,cbo_t1,cbo_t2,cbo_t3,src_cbo,part,lineitem</test.src.tables>
             <java.security.krb5.conf>${test.tmp.dir}/conf/krb5.conf</java.security.krb5.conf>
           </systemPropertyVariables>
         </configuration>

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q Thu Nov  6 18:59:36 2014
@@ -1,19 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 -- testAggrFuncsWithNoGBYNoPartDef
 select p_mfgr, 
 sum(p_retailprice) as s1  

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q Thu Nov  6 18:59:36 2014
@@ -1,19 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 -- testAmbiguousWindowDefn
 select p_mfgr, p_name, p_size, 
 sum(p_size) over (w1) as s1, 

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DistributeByOrderBy.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DistributeByOrderBy.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DistributeByOrderBy.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DistributeByOrderBy.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testPartitonBySortBy
 select p_mfgr, p_name, p_size,
 sum(p_retailprice) over (distribute by p_mfgr order by p_mfgr) as s1

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testDuplicateWindowAlias
 select p_mfgr, p_name, p_size, 
 sum(p_size) over (w1) as s1, 

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testHavingLeadWithNoGBYNoWindowing
 select  p_mfgr,p_name, p_size 
 from part 

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithPTF.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithPTF.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithPTF.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithPTF.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testHavingLeadWithPTF
 select  p_mfgr,p_name, p_size 
 from noop(on part 

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q Thu Nov  6 18:59:36 2014
@@ -1,21 +1,6 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING,
-    p_complex array<int>
-);
-
 -- testInvalidValueBoundary
 select  p_mfgr,p_name, p_size,   
 sum(p_size) over (w1) as s ,    
 dense_rank() over(w1) as dr  
-from part  
+from part
 window w1 as (partition by p_mfgr order by p_complex range between  2 preceding and current row);

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_JoinWithAmbigousAlias.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_JoinWithAmbigousAlias.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_JoinWithAmbigousAlias.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_JoinWithAmbigousAlias.q Thu Nov  6 18:59:36 2014
@@ -1,20 +1,6 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testJoinWithAmbigousAlias
 select abc.* 
-from noop(on part 
+from noop(on part
 partition by p_mfgr 
 order by p_name 
 ) abc join part on abc.p_partkey = p1.p_partkey;

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_PartitionBySortBy.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_PartitionBySortBy.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_PartitionBySortBy.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_PartitionBySortBy.q Thu Nov  6 18:59:36 2014
@@ -1,19 +1,5 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testPartitonBySortBy
 select p_mfgr, p_name, p_size,
 sum(p_retailprice) over (partition by p_mfgr sort by p_mfgr) as s1
-from part 
+from part
 ;

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_WhereWithRankCond.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_WhereWithRankCond.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_WhereWithRankCond.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_negative_WhereWithRankCond.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 -- testWhereWithRankCond
 select  p_mfgr,p_name, p_size, 
 rank() over() as r 

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries.q Thu Nov  6 18:59:36 2014
@@ -1,16 +1,3 @@
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 select p_mfgr, p_name, p_size,
     sum(p_retailprice) over (rows unbounded following) as s1 
      from part distribute by p_mfgr sort by p_name;

Modified: hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries2.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries2.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries2.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/ptf_window_boundaries2.q Thu Nov  6 18:59:36 2014
@@ -1,16 +1,3 @@
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 select p_mfgr, p_name, p_size,
     sum(p_retailprice) over (range unbounded following) as s1
      from part distribute by p_mfgr sort by p_name;

Modified: hive/trunk/ql/src/test/queries/clientnegative/subquery_nested_subquery.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/subquery_nested_subquery.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/subquery_nested_subquery.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/subquery_nested_subquery.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 select *
 from part x 
 where x.p_name in (select y.p_name from part y where exists (select z.p_name from part z where y.p_name = z.p_name))

Modified: hive/trunk/ql/src/test/queries/clientnegative/subquery_windowing_corr.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/subquery_windowing_corr.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/subquery_windowing_corr.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/subquery_windowing_corr.q Thu Nov  6 18:59:36 2014
@@ -1,21 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
-
 -- corr and windowing 
 select p_mfgr, p_name, p_size 
 from part a 

Modified: hive/trunk/ql/src/test/queries/clientnegative/windowing_leadlag_in_udaf.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/windowing_leadlag_in_udaf.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/windowing_leadlag_in_udaf.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/windowing_leadlag_in_udaf.q Thu Nov  6 18:59:36 2014
@@ -1,15 +1 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 select sum(lead(p_retailprice,1)) as s1  from part;

Modified: hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_neg.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_neg.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_neg.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_neg.q Thu Nov  6 18:59:36 2014
@@ -1,21 +1,3 @@
-DROP TABLE IF EXISTS part;
-
--- data setup
-CREATE TABLE part(
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
-
 select p_mfgr, p_name, p_size,
 min(p_retailprice),
 rank() over(distribute by p_mfgr sort by p_name)as r,

Modified: hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_over.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_over.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_over.q (original)
+++ hive/trunk/ql/src/test/queries/clientnegative/windowing_ll_no_over.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,3 @@
-DROP TABLE part;
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 select p_mfgr, 
 lead(p_retailprice,1) as s1  
 from part;

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_gby.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_gby.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_gby.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_gby.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,21 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 6. Test Select + TS + Join + Fil + GB + GB Having
+select * from cbo_t1 group by c_int;
+select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key;
+select * from (select key, (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key) R group by y, x;
+
+select * 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 order by a) cbo_t1 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 order by q/10 desc, r asc) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c order by cbo_t3.c_int+c desc, c;
+
+select * 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 b % c asc, b desc) cbo_t1 left outer 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) cbo_t2 on cbo_t1.a=p left outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c  having cbo_t3.c_int > 0 and (c_int >=1 or c >= 1) and (c_int + c) >= 0  order by cbo_t3.c_int % c asc, cbo_t3.c_int desc;
+
+select * 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 b+c, a desc) cbo_t1 right outer 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) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 2) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c;
+
+select * 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 c+a desc) cbo_t1 full outer 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 p+q desc, r asc) cbo_t2 on cbo_t1.a=p full outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c having cbo_t3.c_int > 0 and (c_int >=1 or c >= 1) and (c_int + c) >= 0 order by cbo_t3.c_int;
+
+select * 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) cbo_t1 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) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_gby_empty.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_gby_empty.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_gby_empty.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_gby_empty.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,29 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 21. Test groupby is empty and there is no other cols in aggr
+select unionsrc.key FROM (select 'tst1' as key, count(1) as value from src) unionsrc;
+
+select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src) unionsrc;
+
+select unionsrc.key FROM (select 'max' as key, max(c_int) as value from cbo_t3 s1
+	UNION  ALL
+    	select 'min' as key,  min(c_int) as value from cbo_t3 s2
+    UNION ALL
+        select 'avg' as key,  avg(c_int) as value from cbo_t3 s3) unionsrc order by unionsrc.key;
+        
+select unionsrc.key, unionsrc.value FROM (select 'max' as key, max(c_int) as value from cbo_t3 s1
+	UNION  ALL
+    	select 'min' as key,  min(c_int) as value from cbo_t3 s2
+    UNION ALL
+        select 'avg' as key,  avg(c_int) as value from cbo_t3 s3) unionsrc order by unionsrc.key;
+
+select unionsrc.key, count(1) FROM (select 'max' as key, max(c_int) as value from cbo_t3 s1
+    UNION  ALL
+        select 'min' as key,  min(c_int) as value from cbo_t3 s2
+    UNION ALL
+        select 'avg' as key,  avg(c_int) as value from cbo_t3 s3) unionsrc group by unionsrc.key order by unionsrc.key;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_join.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_join.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_join.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_join.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,63 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 4. Test Select + Join + TS
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 join             cbo_t2 on cbo_t1.key=cbo_t2.key;
+select cbo_t1.key from cbo_t1 join cbo_t3;
+select cbo_t1.key from cbo_t1 join cbo_t3 where cbo_t1.key=cbo_t3.key and cbo_t1.key >= 1;
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 left outer join  cbo_t2 on cbo_t1.key=cbo_t2.key;
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 right outer join cbo_t2 on cbo_t1.key=cbo_t2.key;
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 full outer join  cbo_t2 on cbo_t1.key=cbo_t2.key;
+
+select b, cbo_t1.c, cbo_t2.p, q, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key;
+select key, cbo_t1.c_int, cbo_t2.p, q from cbo_t1 join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.key=p join (select key as a, c_int as b, cbo_t3.c_float as c from cbo_t3)cbo_t3 on cbo_t1.key=a;
+select a, cbo_t1.b, key, cbo_t2.c_int, cbo_t3.p from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 join cbo_t2  on cbo_t1.a=key join (select key as p, c_int as q, cbo_t3.c_float as r from cbo_t3)cbo_t3 on cbo_t1.a=cbo_t3.p;
+select b, cbo_t1.c, cbo_t2.c_int, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 join cbo_t2 on cbo_t1.a=cbo_t2.key join cbo_t3 on cbo_t1.a=cbo_t3.key;
+select cbo_t3.c_int, b, cbo_t2.c_int, cbo_t1.c from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 join cbo_t2 on cbo_t1.a=cbo_t2.key join cbo_t3 on cbo_t1.a=cbo_t3.key;
+
+select b, cbo_t1.c, cbo_t2.p, q, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 left outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key;
+select key, cbo_t1.c_int, cbo_t2.p, q from cbo_t1 join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.key=p left outer join (select key as a, c_int as b, cbo_t3.c_float as c from cbo_t3)cbo_t3 on cbo_t1.key=a;
+
+select b, cbo_t1.c, cbo_t2.p, q, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 right outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key;
+select key, cbo_t1.c_int, cbo_t2.p, q from cbo_t1 join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.key=p right outer join (select key as a, c_int as b, cbo_t3.c_float as c from cbo_t3)cbo_t3 on cbo_t1.key=a;
+
+select b, cbo_t1.c, cbo_t2.p, q, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1) cbo_t1 full outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key;
+select key, cbo_t1.c_int, cbo_t2.p, q from cbo_t1 join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2) cbo_t2 on cbo_t1.key=p full outer join (select key as a, c_int as b, cbo_t3.c_float as c from cbo_t3)cbo_t3 on cbo_t1.key=a;
+
+-- 5. Test Select + Join + FIL + TS
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 join cbo_t2 on cbo_t1.key=cbo_t2.key where (cbo_t1.c_int + cbo_t2.c_int == 2) and (cbo_t1.c_int > 0 or cbo_t2.c_float >= 0);
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 left outer join  cbo_t2 on cbo_t1.key=cbo_t2.key where (cbo_t1.c_int + cbo_t2.c_int == 2) and (cbo_t1.c_int > 0 or cbo_t2.c_float >= 0);
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 right outer join cbo_t2 on cbo_t1.key=cbo_t2.key where (cbo_t1.c_int + cbo_t2.c_int == 2) and (cbo_t1.c_int > 0 or cbo_t2.c_float >= 0);
+select cbo_t1.c_int, cbo_t2.c_int from cbo_t1 full outer join  cbo_t2 on cbo_t1.key=cbo_t2.key where (cbo_t1.c_int + cbo_t2.c_int == 2) and (cbo_t1.c_int > 0 or cbo_t2.c_float >= 0);
+
+select b, cbo_t1.c, cbo_t2.p, q, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or cbo_t2.q >= 0);
+
+select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0);
+
+select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 right outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0);
+
+select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 full outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 full outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p left outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p full outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 right outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 right outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p left outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 right outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p full outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 full outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p full outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 full outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p left outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+
+select * from (select q, b, cbo_t2.p, cbo_t1.c, cbo_t3.c_int from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 full outer join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q == 2) and (b > 0 or c_int >= 0)) R where  (q + 1 = 2) and (R.b > 0 or c_int >= 0);
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_limit.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_limit.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_limit.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_limit.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,16 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 7. Test Select + TS + Join + Fil + GB + GB Having + Limit
+select * from cbo_t1 group by c_int limit 1;
+select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key order by x limit 1;
+select * from (select key, (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key) R group by y, x order by x,y limit 1;
+select key from(select key from (select key from cbo_t1 limit 5)cbo_t2  limit 5)cbo_t3  limit 5;
+select key, c_int from(select key, c_int from (select key, c_int from cbo_t1 order by c_int limit 5)cbo_t1  order by c_int limit 5)cbo_t2  order by c_int limit 5;
+
+select * 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 order by a limit 5) cbo_t1 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 order by q/10 desc, r asc limit 5) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c order by cbo_t3.c_int+c desc, c limit 5;
+
+select * 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 b % c asc, b desc limit 5) cbo_t1 left outer 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 limit 5) cbo_t2 on cbo_t1.a=p left outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c  having cbo_t3.c_int > 0 and (c_int >=1 or c >= 1) and (c_int + c) >= 0  order by cbo_t3.c_int % c asc, cbo_t3.c_int desc limit 5;

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_semijoin.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_semijoin.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_semijoin.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_semijoin.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,16 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 12. SemiJoin
+select cbo_t1.c_int           from cbo_t1 left semi join   cbo_t2 on cbo_t1.key=cbo_t2.key;
+select cbo_t1.c_int           from cbo_t1 left semi join   cbo_t2 on cbo_t1.key=cbo_t2.key where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0);
+select * from (select c, b, a from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left semi join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p left semi join cbo_t3 on cbo_t1.a=key where (b + 1 == 2) and (b > 0 or c >= 0)) R where  (b + 1 = 2) and (R.b > 0 or c >= 0);
+select * from (select cbo_t3.c_int, cbo_t1.c, b from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 = 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left semi join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p left outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t3.c_int  == 2) and (b > 0 or c_int >= 0)) R where  (R.c_int + 1 = 2) and (R.b > 0 or c_int >= 0);
+select * from (select c_int, b, cbo_t1.c from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left semi join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + 1 == 2) and (b > 0 or c_int >= 0)) R where  (c + 1 = 2) and (R.b > 0 or c_int >= 0);
+select * from (select c_int, b, cbo_t1.c from (select key as a, c_int as b, cbo_t1.c_float as c from cbo_t1  where (cbo_t1.c_int + 1 == 2) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)) cbo_t1 left semi join (select cbo_t2.key as p, cbo_t2.c_int as q, c_float as r from cbo_t2  where (cbo_t2.c_int + 1 == 2) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)) cbo_t2 on cbo_t1.a=p full outer join cbo_t3 on cbo_t1.a=key where (b + 1 == 2) and (b > 0 or c_int >= 0)) R where  (c + 1 = 2) and (R.b > 0 or c_int >= 0);
+select * 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) 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) 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;
+select * 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;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_simple_select.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_simple_select.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_simple_select.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_simple_select.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,54 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 1. Test Select + TS
+select * from cbo_t1;
+select * from cbo_t1 as cbo_t1;
+select * from cbo_t1 as cbo_t2;
+
+select cbo_t1.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1; 
+
+-- 2. Test Select + TS + FIL
+select * from cbo_t1 where cbo_t1.c_int >= 0;
+select * from cbo_t1 as cbo_t1  where cbo_t1.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+select * from cbo_t1 as cbo_t2 where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+
+select cbo_t2.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1 as cbo_t2  where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+
+-- 3 Test Select + Select + TS + FIL
+select * from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t1;
+select * from (select * from cbo_t1 as cbo_t1  where cbo_t1.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1;
+select * from (select * from cbo_t1 as cbo_t2 where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1;
+select * from (select cbo_t2.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1 as cbo_t2  where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1;
+
+select * from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t1 where cbo_t1.c_int >= 0;
+select * from (select * from cbo_t1 as cbo_t1  where cbo_t1.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1  where cbo_t1.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+select * from (select * from cbo_t1 as cbo_t2 where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t2 where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+select * from (select cbo_t2.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1 as cbo_t2  where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1 where cbo_t1.c_int >= 0 and y+c_int >= 0 or x <= 100;
+
+select cbo_t1.c_int+c_float as x , c_int as c_int, (((c_int+c_float)*10)+5) as y from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t1 where cbo_t1.c_int >= 0;
+select cbo_t2.c_int+c_float as x , c_int as c_int, (((c_int+c_float)*10)+5) as y from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t2 where cbo_t2.c_int >= 0;
+
+
+
+select * from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t1 where cbo_t1.c_int >= 0;
+select * from (select * from cbo_t1 as cbo_t1  where cbo_t1.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1  where cbo_t1.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+select * from (select * from cbo_t1 as cbo_t2 where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t2 where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100;
+select * from (select cbo_t2.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1 as cbo_t2  where cbo_t2.c_int >= 0 and c_float+c_int >= 0 or c_float <= 100) as cbo_t1 where cbo_t1.c_int >= 0 and y+c_int >= 0 or x <= 100;
+
+select cbo_t1.c_int+c_float as x , c_int as c_int, (((c_int+c_float)*10)+5) as y from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t1 where cbo_t1.c_int >= 0;
+select cbo_t2.c_int+c_float as x , c_int as c_int, (((c_int+c_float)*10)+5) as y from (select * from cbo_t1 where cbo_t1.c_int >= 0) as cbo_t2 where cbo_t2.c_int >= 0;
+
+
+
+-- 13. null expr in select list
+select null from cbo_t3;
+
+-- 14. unary operator
+select key from cbo_t1 where c_int = -6  or c_int = +6;
+
+-- 15. query referencing only partition columns
+select count(cbo_t1.dt) from cbo_t1 join cbo_t2 on cbo_t1.dt  = cbo_t2.dt  where cbo_t1.dt = '2014' ;

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_stats.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_stats.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_stats.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_stats.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,9 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 20. Test get stats with empty partition list
+select cbo_t1.value from cbo_t1 join cbo_t2 on cbo_t1.key = cbo_t2.key where cbo_t1.dt = '10' and cbo_t1.c_boolean = true;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_exists.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_exists.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_exists.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_exists.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,66 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 18. SubQueries Not Exists
+-- distinct, corr
+select * 
+from src_cbo b 
+where not exists 
+  (select distinct a.key 
+  from src_cbo a 
+  where b.value = a.value and a.value > 'val_2'
+  )
+;
+
+-- no agg, corr, having
+select * 
+from src_cbo b 
+group by key, value
+having not exists 
+  (select a.key 
+  from src_cbo a 
+  where b.value = a.value  and a.key = b.key and a.value > 'val_12'
+  )
+;
+
+-- 19. SubQueries Exists
+-- view test
+create view cv1 as 
+select * 
+from src_cbo b 
+where exists
+  (select a.key 
+  from src_cbo a 
+  where b.value = a.value  and a.key = b.key and a.value > 'val_9')
+;
+
+select * from cv1
+;
+
+-- sq in from
+select * 
+from (select * 
+      from src_cbo b 
+      where exists 
+          (select a.key 
+          from src_cbo a 
+          where b.value = a.value  and a.key = b.key and a.value > 'val_9')
+     ) a
+;
+
+-- sq in from, having
+select *
+from (select b.key, count(*) 
+  from src_cbo b 
+  group by b.key
+  having exists 
+    (select a.key 
+    from src_cbo a 
+    where a.key = b.key and a.value > 'val_9'
+    )
+) a
+;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_in.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_in.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_in.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_in.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,54 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 17. SubQueries In
+-- non agg, non corr
+select * 
+from src_cbo 
+where src_cbo.key in (select key from src_cbo s1 where s1.key > '9')
+;
+
+-- agg, corr
+-- add back once rank issue fixed for cbo
+
+-- distinct, corr
+select * 
+from src_cbo b 
+where b.key in
+        (select distinct a.key 
+         from src_cbo a 
+         where b.value = a.value and a.key > '9'
+        )
+;
+
+-- non agg, corr, with join in Parent Query
+select p.p_partkey, li.l_suppkey 
+from (select distinct l_partkey as p_partkey from lineitem) p join lineitem li on p.p_partkey = li.l_partkey 
+where li.l_linenumber = 1 and
+ li.l_orderkey in (select l_orderkey from lineitem where l_shipmode = 'AIR' and l_linenumber = li.l_linenumber)
+;
+
+-- where and having
+-- Plan is:
+-- Stage 1: b semijoin sq1:src_cbo (subquery in where)
+-- Stage 2: group by Stage 1 o/p
+-- Stage 5: group by on sq2:src_cbo (subquery in having)
+-- Stage 6: Stage 2 o/p semijoin Stage 5
+select key, value, count(*) 
+from src_cbo b
+where b.key in (select key from src_cbo where src_cbo.key > '8')
+group by key, value
+having count(*) in (select count(*) from src_cbo s1 where s1.key > '9' group by s1.key )
+;
+
+-- non agg, non corr, windowing
+select p_mfgr, p_name, avg(p_size) 
+from part 
+group by p_mfgr, p_name
+having p_name in 
+  (select first_value(p_name) over(partition by p_mfgr order by p_size) from part)
+;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_not_in.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_not_in.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_not_in.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_subq_not_in.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,80 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 16. SubQueries Not In
+-- non agg, non corr
+select * 
+from src_cbo 
+where src_cbo.key not in  
+  ( select key  from src_cbo s1 
+    where s1.key > '2'
+  ) order by key
+;
+
+-- non agg, corr
+select p_mfgr, b.p_name, p_size 
+from part b 
+where b.p_name not in 
+  (select p_name 
+  from (select p_mfgr, p_name, p_size as r from part) a 
+  where r < 10 and b.p_mfgr = a.p_mfgr 
+  )
+;
+
+-- agg, non corr
+select p_name, p_size 
+from 
+part where part.p_size not in 
+  (select avg(p_size) 
+  from (select p_size from part) a 
+  where p_size < 10
+  ) order by p_name
+;
+
+-- agg, corr
+select p_mfgr, p_name, p_size 
+from part b where b.p_size not in 
+  (select min(p_size) 
+  from (select p_mfgr, p_size from part) a 
+  where p_size < 10 and b.p_mfgr = a.p_mfgr
+  ) order by  p_name
+;
+
+-- non agg, non corr, Group By in Parent Query
+select li.l_partkey, count(*) 
+from lineitem li 
+where li.l_linenumber = 1 and 
+  li.l_orderkey not in (select l_orderkey from lineitem where l_shipmode = 'AIR') 
+group by li.l_partkey
+;
+
+-- add null check test from sq_notin.q once HIVE-7721 resolved.
+
+-- non agg, corr, having
+select b.p_mfgr, min(p_retailprice) 
+from part b 
+group by b.p_mfgr
+having b.p_mfgr not in 
+  (select p_mfgr 
+  from (select p_mfgr, min(p_retailprice) l, max(p_retailprice) r, avg(p_retailprice) a from part group by p_mfgr) a 
+  where min(p_retailprice) = l and r - l > 600
+  )
+  order by b.p_mfgr
+;
+
+-- agg, non corr, having
+select b.p_mfgr, min(p_retailprice) 
+from part b 
+group by b.p_mfgr
+having b.p_mfgr not in 
+  (select p_mfgr 
+  from part a
+  group by p_mfgr
+  having max(p_retailprice) - min(p_retailprice) > 600
+  )
+  order by b.p_mfgr  
+;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_udf_udaf.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_udf_udaf.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_udf_udaf.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_udf_udaf.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,17 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 8. Test UDF/UDAF
+select count(*), count(c_int), sum(c_int), avg(c_int), max(c_int), min(c_int) from cbo_t1;
+select count(*), count(c_int), sum(c_int), avg(c_int), max(c_int), min(c_int), case c_int when 0  then 1 when 1 then 2 else 3 end, sum(case c_int when 0  then 1 when 1 then 2 else 3 end) from cbo_t1 group by c_int;
+select * from (select count(*) as a, count(distinct c_int) as b, sum(c_int) as c, avg(c_int) as d, max(c_int) as e, min(c_int) as f from cbo_t1) cbo_t1;
+select * from (select count(*) as a, count(distinct c_int) as b, sum(c_int) as c, avg(c_int) as d, max(c_int) as e, min(c_int) as f, case c_int when 0  then 1 when 1 then 2 else 3 end as g, sum(case c_int when 0  then 1 when 1 then 2 else 3 end) as h from cbo_t1 group by c_int) cbo_t1;
+select f,a,e,b from (select count(*) as a, count(c_int) as b, sum(c_int) as c, avg(c_int) as d, max(c_int) as e, min(c_int) as f from cbo_t1) cbo_t1;
+select f,a,e,b from (select count(*) as a, count(distinct c_int) as b, sum(distinct c_int) as c, avg(distinct c_int) as d, max(distinct c_int) as e, min(distinct c_int) as f from cbo_t1) cbo_t1;
+select count(c_int) as a, avg(c_float), key from cbo_t1 group by key;
+select count(distinct c_int) as a, avg(c_float) from cbo_t1 group by c_float;
+select count(distinct c_int) as a, avg(c_float) from cbo_t1 group by c_int;
+select count(distinct c_int) as a, avg(c_float) from cbo_t1 group by c_float, c_int;

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,11 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 11. Union All
+select * from cbo_t1 order by key, c_boolean, value, dt union all select * from cbo_t2 order by key, c_boolean, value, dt;
+select key from (select key, c_int from (select * from cbo_t1 union all select * from cbo_t2 where cbo_t2.key >=0)r1 union all select key, c_int from cbo_t3)r2 where key >=0 order by key;
+select r2.key from (select key, c_int from (select key, c_int from cbo_t1 union all select key, c_int from cbo_t3 )r1 union all select key, c_int from cbo_t3)r2 join   (select key, c_int from (select * from cbo_t1 union all select * from cbo_t2 where cbo_t2.key >=0)r1 union all select key, c_int from cbo_t3)r3 on r2.key=r3.key where r3.key >=0 order by r2.key;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_views.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_views.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_views.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_views.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,45 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 10. Test views
+create view v1 as select c_int, value, c_boolean, dt from cbo_t1;
+create view v2 as select c_int, value from cbo_t2;
+
+select value from v1 where c_boolean=false;
+select max(c_int) from v1 group by (c_boolean);
+
+select count(v1.c_int)  from v1 join cbo_t2 on v1.c_int = cbo_t2.c_int;
+select count(v1.c_int)  from v1 join v2 on v1.c_int = v2.c_int;
+
+select count(*) from v1 a join v1 b on a.value = b.value;
+
+create view v3 as select v1.value val from v1 join cbo_t1 on v1.c_boolean = cbo_t1.c_boolean;
+
+select count(val) from v3 where val != '1';
+with q1 as ( select key from cbo_t1 where key = '1')
+select count(*) from q1;
+
+with q1 as ( select value from v1 where c_boolean = false)
+select count(value) from q1 ;
+
+create view v4 as
+with q1 as ( select key,c_int from cbo_t1  where key = '1')
+select * from q1
+;
+
+with q1 as ( select c_int from q2 where c_boolean = false),
+q2 as ( select c_int,c_boolean from v1  where value = '1')
+select sum(c_int) from (select c_int from q1) a;
+
+with q1 as ( select cbo_t1.c_int c_int from q2 join cbo_t1 where q2.c_int = cbo_t1.c_int  and cbo_t1.dt='2014'),
+q2 as ( select c_int,c_boolean from v1  where value = '1' or dt = '14')
+select count(*) from q1 join q2 join v4 on q1.c_int = q2.c_int and v4.c_int = q2.c_int;
+
+
+drop view v1;
+drop view v2;
+drop view v3;
+drop view v4;

Added: hive/trunk/ql/src/test/queries/clientpositive/cbo_windowing.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_windowing.q?rev=1637182&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_windowing.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_windowing.q Thu Nov  6 18:59:36 2014
@@ -0,0 +1,18 @@
+set hive.cbo.enable=true;
+set hive.exec.check.crossproducts=false;
+
+set hive.stats.fetch.column.stats=true;
+set hive.auto.convert.join=false;
+
+-- 9. Test Windowing Functions
+select count(c_int) over() from cbo_t1;
+select count(c_int) over(), sum(c_float) over(), max(c_int) over(), min(c_int) over(), row_number() over(), rank() over(), dense_rank() over(), percent_rank() over(), lead(c_int, 2, c_int) over(), lag(c_float, 2, c_float) over() from cbo_t1;
+select * from (select count(c_int) over(), sum(c_float) over(), max(c_int) over(), min(c_int) over(), row_number() over(), rank() over(), dense_rank() over(), percent_rank() over(), lead(c_int, 2, c_int) over(), lag(c_float, 2, c_float) over() from cbo_t1) cbo_t1;
+select x from (select count(c_int) over() as x, sum(c_float) over() from cbo_t1) cbo_t1;
+select 1+sum(c_int) over() from cbo_t1;
+select sum(c_int)+sum(sum(c_int)) over() from cbo_t1;
+select * from (select max(c_int) over (partition by key order by value Rows UNBOUNDED PRECEDING), min(c_int) over (partition by key order by value rows current row), count(c_int) over(partition by key order by value ROWS 1 PRECEDING), avg(value) over (partition by key order by value Rows between unbounded preceding and unbounded following), sum(value) over (partition by key order by value rows between unbounded preceding and current row), avg(c_float) over (partition by key order by value Rows between 1 preceding and unbounded following), sum(c_float) over (partition by key order by value rows between 1 preceding and current row), max(c_float) over (partition by key order by value rows between 1 preceding and unbounded following), min(c_float) over (partition by key order by value rows between 1 preceding and 1 following) from cbo_t1) cbo_t1;
+select i, a, h, b, c, d, e, f, g, a as x, a +1 as y from (select max(c_int) over (partition by key order by value range UNBOUNDED PRECEDING) a, min(c_int) over (partition by key order by value range current row) b, count(c_int) over(partition by key order by value range 1 PRECEDING) c, avg(value) over (partition by key order by value range between unbounded preceding and unbounded following) d, sum(value) over (partition by key order by value range between unbounded preceding and current row) e, avg(c_float) over (partition by key order by value range between 1 preceding and unbounded following) f, sum(c_float) over (partition by key order by value range between 1 preceding and current row) g, max(c_float) over (partition by key order by value range between 1 preceding and unbounded following) h, min(c_float) over (partition by key order by value range between 1 preceding and 1 following) i from cbo_t1) cbo_t1;
+select *, rank() over(partition by key order by value) as rr from src1;
+select *, rank() over(partition by key order by value) from src1;
+

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_alt_syntax.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_alt_syntax.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_alt_syntax.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_alt_syntax.q Thu Nov  6 18:59:36 2014
@@ -1,20 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 explain select p1.p_name, p2.p_name
 from part p1 , part p2;
 

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_1.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_1.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_1.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_1.q Thu Nov  6 18:59:36 2014
@@ -1,22 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
-
-
 explain select *
 from part p1 join part p2 join part p3 on p1.p_name = p2.p_name and p2.p_name = p3.p_name;
 

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_2.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_2.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_2.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_2.q Thu Nov  6 18:59:36 2014
@@ -1,21 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
-
 explain select *
 from part p1 join part p2 join part p3 on p1.p_name = p2.p_name join part p4 on p2.p_name = p3.p_name and p1.p_name = p4.p_name;
 

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_3.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_3.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_3.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_3.q Thu Nov  6 18:59:36 2014
@@ -1,22 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
-
-
 explain select *
 from part p1 join part p2 join part p3 
 where p1.p_name = p2.p_name and p2.p_name = p3.p_name;

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_4.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_4.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_4.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_4.q Thu Nov  6 18:59:36 2014
@@ -1,21 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
-
 explain select *
 from part p1 join part p2 join part p3 on p1.p_name = p2.p_name join part p4 
 where p2.p_name = p3.p_name and p1.p_name = p4.p_name;

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual1.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual1.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual1.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual1.q Thu Nov  6 18:59:36 2014
@@ -1,20 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 create table part2( 
     p2_partkey INT,
     p2_name STRING,

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual2.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual2.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual2.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual2.q Thu Nov  6 18:59:36 2014
@@ -1,20 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 create table part2( 
     p2_partkey INT,
     p2_name STRING,

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual3.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual3.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual3.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual3.q Thu Nov  6 18:59:36 2014
@@ -1,20 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 create table part2( 
     p2_partkey INT,
     p2_name STRING,

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual4.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual4.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual4.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_cond_pushdown_unqual4.q Thu Nov  6 18:59:36 2014
@@ -1,20 +1,3 @@
-DROP TABLE part;
-
--- data setup
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
-LOAD DATA LOCAL INPATH '../../data/files/part_tiny.txt' overwrite into table part;
-
 create table part2( 
     p2_partkey INT,
     p2_name STRING,

Modified: hive/trunk/ql/src/test/queries/clientpositive/join_merging.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/join_merging.q?rev=1637182&r1=1637181&r2=1637182&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/join_merging.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/join_merging.q Thu Nov  6 18:59:36 2014
@@ -1,17 +1,4 @@
 
-
-CREATE TABLE part( 
-    p_partkey INT,
-    p_name STRING,
-    p_mfgr STRING,
-    p_brand STRING,
-    p_type STRING,
-    p_size INT,
-    p_container STRING,
-    p_retailprice DOUBLE,
-    p_comment STRING
-);
-
 explain select p1.p_size, p2.p_size 
 from part p1 left outer join part p2 on p1.p_partkey = p2.p_partkey 
   right outer join part p3 on p2.p_partkey = p3.p_partkey and