You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by ji...@apache.org on 2015/05/19 04:08:12 UTC

[47/47] tajo git commit: TAJO-1577: Add test cases to verify join plans. (jihoon)

TAJO-1577: Add test cases to verify join plans. (jihoon)

Closes #571


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

Branch: refs/heads/master
Commit: 4b1b7799d9852d8b75ccac00bec5543e1f0c859b
Parents: 3870a61
Author: Jihoon Son <ji...@apache.org>
Authored: Tue May 19 11:06:37 2015 +0900
Committer: Jihoon Son <ji...@apache.org>
Committed: Tue May 19 11:06:37 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |    2 +
 .../physical/PartitionMergeScanExec.java        |   27 +-
 .../engine/planner/physical/SeqScanExec.java    |    3 -
 .../exec/ExplainPlanPreprocessorForTest.java    |  137 +-
 .../test/java/org/apache/tajo/NamedTest.java    |   27 +
 .../java/org/apache/tajo/QueryTestCaseBase.java |  195 ++-
 .../org/apache/tajo/TajoTestingCluster.java     |   20 +-
 .../engine/function/TestBuiltinFunctions.java   |  132 +-
 .../planner/global/TestBroadcastJoinPlan.java   | 1044 ---------------
 .../tajo/engine/query/TestGroupByQuery.java     |   34 +-
 .../tajo/engine/query/TestInnerJoinQuery.java   |  335 +++++
 .../engine/query/TestInnerJoinWithSubQuery.java |  125 ++
 .../tajo/engine/query/TestJoinBroadcast.java    |  850 ------------
 .../query/TestJoinOnPartitionedTables.java      |  337 ++++-
 .../apache/tajo/engine/query/TestJoinQuery.java | 1241 +++---------------
 .../engine/query/TestMultipleJoinTypes.java     |  105 ++
 .../tajo/engine/query/TestOuterJoinQuery.java   |  462 +++++++
 .../engine/query/TestOuterJoinWithSubQuery.java |  142 ++
 .../tajo/engine/query/TestSelectQuery.java      |   38 +-
 .../apache/tajo/engine/query/TestSortQuery.java |   14 +-
 .../customer_large/customer.tbl                 |  100 --
 .../lineitem_large/lineitem.tbl                 |   97 --
 .../TestJoinBroadcast/orders_large/orders.tbl   |  300 -----
 .../testDistinctAggregationCaseByCase4.sql      |    2 +-
 .../testGroupByWithNullData5.sql                |    2 +-
 .../testGroupByWithNullData6.sql                |    2 +-
 .../testGroupByWithNullData7.sql                |    2 +-
 .../testGroupByWithNullData8.sql                |    2 +-
 .../testBroadcastTwoPartJoin.sql                |   19 +
 .../testCrossJoinAndCaseWhen.sql                |   18 +
 .../testCrossJoinWithAsterisk1.sql              |    1 +
 .../testCrossJoinWithAsterisk2.sql              |    1 +
 .../testCrossJoinWithAsterisk3.sql              |    1 +
 .../testCrossJoinWithAsterisk4.sql              |    1 +
 .../testBroadcastSubquery.sql                   |   12 +
 .../testBroadcastSubquery2.sql                  |   19 +
 .../create_customer_large_ddl.sql               |    7 -
 .../create_lineitem_large_ddl.sql               |    7 -
 .../create_orders_large_ddl.sql                 |    7 -
 .../customer_partition_ddl.sql                  |    9 -
 .../insert_into_customer_partition.sql          |   11 -
 .../TestJoinBroadcast/nation_multifile_ddl.sql  |    5 -
 .../queries/TestJoinBroadcast/oj_table1_ddl.sql |    6 -
 .../queries/TestJoinBroadcast/oj_table2_ddl.sql |    6 -
 .../TestJoinBroadcast/orders_multifile_ddl.sql  |    5 -
 .../testBroadcastBasicJoin.sql                  |   11 -
 .../testBroadcastPartitionTable.sql             |   16 -
 .../TestJoinBroadcast/testBroadcastSubquery.sql |   12 -
 .../testBroadcastSubquery2.sql                  |   19 -
 .../testBroadcastTwoPartJoin.sql                |   15 -
 .../queries/TestJoinBroadcast/testCrossJoin.sql |    1 -
 .../testCrossJoinAndCaseWhen.sql                |   18 -
 .../testCrossJoinWithAsterisk1.sql              |    1 -
 .../testCrossJoinWithAsterisk2.sql              |    1 -
 .../testCrossJoinWithAsterisk3.sql              |    1 -
 .../testCrossJoinWithAsterisk4.sql              |    1 -
 .../testCrossJoinWithEmptyTable1.sql            |    8 -
 .../TestJoinBroadcast/testFullOuterJoin1.sql    |    8 -
 .../testFullOuterJoinWithEmptyTable1.sql        |    8 -
 .../testInnerJoinWithEmptyTable.sql             |    8 -
 .../testJoinCoReferredEvals1.sql                |   11 -
 .../testJoinCoReferredEvalsWithSameExprs1.sql   |   14 -
 .../testJoinCoReferredEvalsWithSameExprs2.sql   |   22 -
 .../testJoinOnMultipleDatabases.sql             |   25 -
 .../TestJoinBroadcast/testLeftOuterJoin1.sql    |    9 -
 .../TestJoinBroadcast/testLeftOuterJoin2.sql    |    5 -
 .../TestJoinBroadcast/testLeftOuterJoin3.sql    |    7 -
 .../testLeftOuterJoinWithConstantExpr1.sql      |    9 -
 .../testLeftOuterJoinWithConstantExpr2.sql      |    9 -
 .../testLeftOuterJoinWithConstantExpr3.sql      |   17 -
 .../testLeftOuterJoinWithEmptyTable1.sql        |    9 -
 .../testLeftOuterJoinWithEmptyTable2.sql        |    9 -
 .../testLeftOuterJoinWithEmptyTable3.sql        |   14 -
 .../testLeftOuterJoinWithEmptyTable4.sql        |   17 -
 ...tMultipleBroadcastDataFileWithZeroLength.sql |    3 -
 ...MultipleBroadcastDataFileWithZeroLength2.sql |    5 -
 ...rtitionedBroadcastDataFileWithZeroLength.sql |    3 -
 ...titionedBroadcastDataFileWithZeroLength2.sql |    5 -
 .../testOuterJoinAndCaseWhen1.sql               |   12 -
 .../TestJoinBroadcast/testRightOuterJoin1.sql   |    8 -
 .../testRightOuterJoinWithEmptyTable1.sql       |    8 -
 .../TestJoinBroadcast/testTPCHQ2Join.sql        |   25 -
 .../TestJoinBroadcast/testWhereClauseJoin1.sql  |   10 -
 .../TestJoinBroadcast/testWhereClauseJoin2.sql  |    8 -
 .../TestJoinBroadcast/testWhereClauseJoin3.sql  |    9 -
 .../TestJoinBroadcast/testWhereClauseJoin4.sql  |    8 -
 .../TestJoinBroadcast/testWhereClauseJoin5.sql  |   15 -
 .../TestJoinBroadcast/testWhereClauseJoin6.sql  |   19 -
 .../customer_ddl.sql                            |    9 -
 .../insert_into_customer.sql                    |   11 -
 .../testBroadcastPartitionTable.sql             |   16 +
 ...rtitionedBroadcastDataFileWithZeroLength.sql |    3 +
 ...titionedBroadcastDataFileWithZeroLength2.sql |    5 +
 .../TestJoinQuery/create_customer_large_ddl.sql |    7 +
 .../TestJoinQuery/create_lineitem_large_ddl.sql |    7 +
 .../TestJoinQuery/create_orders_large_ddl.sql   |    7 +
 .../TestJoinQuery/customer_partition_ddl.sql    |    9 +
 .../TestJoinQuery/insert_into_customer.sql      |   11 +
 .../insert_into_customer_partition.sql          |   11 +
 .../TestJoinQuery/nation_multifile_ddl.sql      |    5 +
 .../queries/TestJoinQuery/oj_table1_ddl.sql     |    2 +-
 .../queries/TestJoinQuery/oj_table2_ddl.sql     |    2 +-
 .../TestJoinQuery/orders_multifile_ddl.sql      |    5 +
 .../TestJoinQuery/partitioned_customer_ddl.sql  |   19 +
 .../queries/TestJoinQuery/testCrossJoin.sql     |    1 -
 .../testCrossJoinWithAsterisk1.sql              |    1 -
 .../testCrossJoinWithAsterisk2.sql              |    1 -
 .../testCrossJoinWithAsterisk3.sql              |    1 -
 .../testCrossJoinWithAsterisk4.sql              |    1 -
 .../TestJoinQuery/testOuterJoinAndCaseWhen1.sql |    2 +-
 .../TestOuterJoinQuery/testLeftOuterJoin2.sql   |    5 +
 .../TestOuterJoinQuery/testLeftOuterJoin3.sql   |    7 +
 ...tMultipleBroadcastDataFileWithZeroLength.sql |    3 +
 ...MultipleBroadcastDataFileWithZeroLength2.sql |    5 +
 .../create_table_with_date_ddl.sql              |    2 +-
 .../queries/TestSortQuery/testSortWithDate.sql  |    2 +-
 .../testBroadcastTwoPartJoin.Hash.plan          |  168 +++
 ...stBroadcastTwoPartJoin.Hash_NoBroadcast.plan |  249 ++++
 .../testBroadcastTwoPartJoin.Sort.plan          |  168 +++
 ...stBroadcastTwoPartJoin.Sort_NoBroadcast.plan |  249 ++++
 .../testBroadcastTwoPartJoin.result             |    7 +
 .../testComplexJoinCondition1.Hash.plan         |   79 ++
 ...tComplexJoinCondition1.Hash_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition1.Sort.plan         |   79 ++
 ...tComplexJoinCondition1.Sort_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition1.result            |   27 +
 .../testComplexJoinCondition2.Hash.plan         |   79 ++
 ...tComplexJoinCondition2.Hash_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition2.Sort.plan         |   79 ++
 ...tComplexJoinCondition2.Sort_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition2.result            |   27 +
 .../testComplexJoinCondition3.Hash.plan         |   79 ++
 ...tComplexJoinCondition3.Hash_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition3.Sort.plan         |   79 ++
 ...tComplexJoinCondition3.Sort_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition3.result            |   27 +
 .../testComplexJoinCondition4.Hash.plan         |   79 ++
 ...tComplexJoinCondition4.Hash_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition4.Sort.plan         |   79 ++
 ...tComplexJoinCondition4.Sort_NoBroadcast.plan |  105 ++
 .../testComplexJoinCondition4.result            |   29 +
 .../testCrossJoin.1.Hash.plan                   |   77 ++
 .../testCrossJoin.1.Hash_NoBroadcast.plan       |  103 ++
 .../testCrossJoin.1.Sort.plan                   |   77 ++
 .../testCrossJoin.1.Sort_NoBroadcast.plan       |  103 ++
 .../TestInnerJoinQuery/testCrossJoin.1.result   |  127 ++
 .../testCrossJoin.2.Hash.plan                   |   52 +
 .../testCrossJoin.2.Hash_NoBroadcast.plan       |   78 ++
 .../testCrossJoin.2.Sort.plan                   |   52 +
 .../testCrossJoin.2.Sort_NoBroadcast.plan       |   78 ++
 .../TestInnerJoinQuery/testCrossJoin.2.result   |   27 +
 .../testCrossJoin.3.Hash.plan                   |   52 +
 .../testCrossJoin.3.Hash_NoBroadcast.plan       |   78 ++
 .../testCrossJoin.3.Sort.plan                   |   52 +
 .../testCrossJoin.3.Sort_NoBroadcast.plan       |   78 ++
 .../TestInnerJoinQuery/testCrossJoin.3.result   |   27 +
 .../testCrossJoin.4.Hash.plan                   |   52 +
 .../testCrossJoin.4.Hash_NoBroadcast.plan       |   78 ++
 .../testCrossJoin.4.Sort.plan                   |   52 +
 .../testCrossJoin.4.Sort_NoBroadcast.plan       |   78 ++
 .../TestInnerJoinQuery/testCrossJoin.4.result   |   27 +
 .../testCrossJoin.5.Hash.plan                   |   77 ++
 .../testCrossJoin.5.Hash_NoBroadcast.plan       |  103 ++
 .../testCrossJoin.5.Sort.plan                   |   77 ++
 .../testCrossJoin.5.Sort_NoBroadcast.plan       |  103 ++
 .../TestInnerJoinQuery/testCrossJoin.5.result   |   27 +
 .../testCrossJoinAndCaseWhen.Hash.plan          |   79 ++
 ...stCrossJoinAndCaseWhen.Hash_NoBroadcast.plan |  105 ++
 .../testCrossJoinAndCaseWhen.Sort.plan          |   79 ++
 ...stCrossJoinAndCaseWhen.Sort_NoBroadcast.plan |  105 ++
 .../testCrossJoinAndCaseWhen.result             |   27 +
 .../testCrossJoinWithAsterisk1.Hash.plan        |   77 ++
 ...CrossJoinWithAsterisk1.Hash_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk1.Sort.plan        |   77 ++
 ...CrossJoinWithAsterisk1.Sort_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk1.result           |   27 +
 .../testCrossJoinWithAsterisk2.Hash.plan        |   77 ++
 ...CrossJoinWithAsterisk2.Hash_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk2.Sort.plan        |   77 ++
 ...CrossJoinWithAsterisk2.Sort_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk2.result           |   27 +
 .../testCrossJoinWithAsterisk3.Hash.plan        |   77 ++
 ...CrossJoinWithAsterisk3.Hash_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk3.Sort.plan        |   77 ++
 ...CrossJoinWithAsterisk3.Sort_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk3.result           |   27 +
 .../testCrossJoinWithAsterisk4.Hash.plan        |   77 ++
 ...CrossJoinWithAsterisk4.Hash_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk4.Sort.plan        |   77 ++
 ...CrossJoinWithAsterisk4.Sort_NoBroadcast.plan |  103 ++
 .../testCrossJoinWithAsterisk4.result           |   27 +
 .../testCrossJoinWithEmptyTable1.Hash.plan      |   79 ++
 ...ossJoinWithEmptyTable1.Hash_NoBroadcast.plan |  105 ++
 .../testCrossJoinWithEmptyTable1.Sort.plan      |   79 ++
 ...ossJoinWithEmptyTable1.Sort_NoBroadcast.plan |  105 ++
 .../testCrossJoinWithEmptyTable1.result         |    2 +
 ...sJoinWithThetaJoinConditionInWhere.Hash.plan |   64 +
 ...taJoinConditionInWhere.Hash_NoBroadcast.plan |   90 ++
 ...sJoinWithThetaJoinConditionInWhere.Sort.plan |   64 +
 ...taJoinConditionInWhere.Sort_NoBroadcast.plan |   90 ++
 ...rossJoinWithThetaJoinConditionInWhere.result |   12 +
 .../testDifferentTypesJoinCondition.Hash.plan   |   54 +
 ...rentTypesJoinCondition.Hash_NoBroadcast.plan |   80 ++
 .../testDifferentTypesJoinCondition.Sort.plan   |   54 +
 ...rentTypesJoinCondition.Sort_NoBroadcast.plan |   80 ++
 .../testDifferentTypesJoinCondition.result      |    7 +
 .../testInnerJoinAndCaseWhen.Hash.plan          |   79 ++
 ...stInnerJoinAndCaseWhen.Hash_NoBroadcast.plan |  105 ++
 .../testInnerJoinAndCaseWhen.Sort.plan          |   79 ++
 ...stInnerJoinAndCaseWhen.Sort_NoBroadcast.plan |  105 ++
 .../testInnerJoinAndCaseWhen.result             |   27 +
 .../testInnerJoinWithEmptyTable.Hash.plan       |   79 ++
 ...nnerJoinWithEmptyTable.Hash_NoBroadcast.plan |  105 ++
 .../testInnerJoinWithEmptyTable.Sort.plan       |   79 ++
 ...nnerJoinWithEmptyTable.Sort_NoBroadcast.plan |  105 ++
 .../testInnerJoinWithEmptyTable.result          |    2 +
 ...rJoinWithThetaJoinConditionInWhere.Hash.plan |   58 +
 ...taJoinConditionInWhere.Hash_NoBroadcast.plan |   84 ++
 ...rJoinWithThetaJoinConditionInWhere.Sort.plan |   58 +
 ...taJoinConditionInWhere.Sort_NoBroadcast.plan |   84 ++
 ...nnerJoinWithThetaJoinConditionInWhere.result |    7 +
 .../testJoinAsterisk.Hash.plan                  |   54 +
 .../testJoinAsterisk.Hash_NoBroadcast.plan      |   80 ++
 .../testJoinAsterisk.Sort.plan                  |   54 +
 .../testJoinAsterisk.Sort_NoBroadcast.plan      |   80 ++
 .../TestInnerJoinQuery/testJoinAsterisk.result  |    7 +
 .../testJoinCoReferredEvals1.Hash.plan          |   79 ++
 ...stJoinCoReferredEvals1.Hash_NoBroadcast.plan |  105 ++
 .../testJoinCoReferredEvals1.Sort.plan          |   79 ++
 ...stJoinCoReferredEvals1.Sort_NoBroadcast.plan |  105 ++
 .../testJoinCoReferredEvals1.result             |   27 +
 ...tJoinCoReferredEvalsWithSameExprs1.Hash.plan |   89 ++
 ...redEvalsWithSameExprs1.Hash_NoBroadcast.plan |  115 ++
 ...tJoinCoReferredEvalsWithSameExprs1.Sort.plan |   89 ++
 ...redEvalsWithSameExprs1.Sort_NoBroadcast.plan |  115 ++
 ...testJoinCoReferredEvalsWithSameExprs1.result |   22 +
 ...tJoinCoReferredEvalsWithSameExprs2.Hash.plan |  120 ++
 ...redEvalsWithSameExprs2.Hash_NoBroadcast.plan |  146 +++
 ...tJoinCoReferredEvalsWithSameExprs2.Sort.plan |  120 ++
 ...redEvalsWithSameExprs2.Sort_NoBroadcast.plan |  146 +++
 ...testJoinCoReferredEvalsWithSameExprs2.result |   22 +
 .../testJoinOnMultipleDatabases.Hash.plan       |  168 +++
 ...oinOnMultipleDatabases.Hash_NoBroadcast.plan |  249 ++++
 .../testJoinOnMultipleDatabases.Sort.plan       |  168 +++
 ...oinOnMultipleDatabases.Sort_NoBroadcast.plan |  249 ++++
 .../testJoinOnMultipleDatabases.result          |    5 +
 .../testJoinOnMultipleDatabasesWithJson.result  |    5 +
 .../TestInnerJoinQuery/testJoinWithJson.result  |   27 +
 .../testJoinWithMultipleJoinQual1.Hash.plan     |  168 +++
 ...nWithMultipleJoinQual1.Hash_NoBroadcast.plan |  249 ++++
 .../testJoinWithMultipleJoinQual1.Sort.plan     |  168 +++
 ...nWithMultipleJoinQual1.Sort_NoBroadcast.plan |  249 ++++
 .../testJoinWithMultipleJoinQual1.result        |    2 +
 .../testJoinWithOrPredicates.Hash.plan          |   91 ++
 ...stJoinWithOrPredicates.Hash_NoBroadcast.plan |  117 ++
 .../testJoinWithOrPredicates.Sort.plan          |   91 ++
 ...stJoinWithOrPredicates.Sort_NoBroadcast.plan |  117 ++
 .../testJoinWithOrPredicates.result             |    4 +
 .../testNaturalJoin.Hash.plan                   |   79 ++
 .../testNaturalJoin.Hash_NoBroadcast.plan       |  105 ++
 .../testNaturalJoin.Sort.plan                   |   79 ++
 .../testNaturalJoin.Sort_NoBroadcast.plan       |  105 ++
 .../TestInnerJoinQuery/testNaturalJoin.result   |   27 +
 .../TestInnerJoinQuery/testTPCHQ2Join.Hash.plan |  168 +++
 .../testTPCHQ2Join.Hash_NoBroadcast.plan        |  249 ++++
 .../TestInnerJoinQuery/testTPCHQ2Join.Sort.plan |  168 +++
 .../testTPCHQ2Join.Sort_NoBroadcast.plan        |  249 ++++
 .../TestInnerJoinQuery/testTPCHQ2Join.result    |    5 +
 .../testWhereClauseJoin1.Hash.plan              |   79 ++
 .../testWhereClauseJoin1.Hash_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin1.Sort.plan              |   79 ++
 .../testWhereClauseJoin1.Sort_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin1.result                 |   27 +
 .../testWhereClauseJoin2.Hash.plan              |   79 ++
 .../testWhereClauseJoin2.Hash_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin2.Sort.plan              |   79 ++
 .../testWhereClauseJoin2.Sort_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin2.result                 |   27 +
 .../testWhereClauseJoin3.Hash.plan              |   79 ++
 .../testWhereClauseJoin3.Hash_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin3.Sort.plan              |   79 ++
 .../testWhereClauseJoin3.Sort_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin3.result                 |   27 +
 .../testWhereClauseJoin4.Hash.plan              |   79 ++
 .../testWhereClauseJoin4.Hash_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin4.Sort.plan              |   79 ++
 .../testWhereClauseJoin4.Sort_NoBroadcast.plan  |  105 ++
 .../testWhereClauseJoin4.result                 |   27 +
 .../testWhereClauseJoin5.Hash.plan              |   98 ++
 .../testWhereClauseJoin5.Hash_NoBroadcast.plan  |  153 +++
 .../testWhereClauseJoin5.Sort.plan              |   98 ++
 .../testWhereClauseJoin5.Sort_NoBroadcast.plan  |  153 +++
 .../testWhereClauseJoin5.result                 |    5 +
 .../testWhereClauseJoin6.Hash.plan              |  117 ++
 .../testWhereClauseJoin6.Hash_NoBroadcast.plan  |  201 +++
 .../testWhereClauseJoin6.Sort.plan              |  117 ++
 .../testWhereClauseJoin6.Sort_NoBroadcast.plan  |  201 +++
 .../testWhereClauseJoin6.result                 |    5 +
 .../testBroadcastSubquery.Hash.plan             |  165 +++
 .../testBroadcastSubquery.Hash_NoBroadcast.plan |  165 +++
 .../testBroadcastSubquery.Sort.plan             |  165 +++
 .../testBroadcastSubquery.Sort_NoBroadcast.plan |  165 +++
 .../testBroadcastSubquery.result                |    7 +
 .../testBroadcastSubquery2.Hash.plan            |  276 ++++
 ...testBroadcastSubquery2.Hash_NoBroadcast.plan |  328 +++++
 .../testBroadcastSubquery2.Sort.plan            |  276 ++++
 ...testBroadcastSubquery2.Sort_NoBroadcast.plan |  328 +++++
 .../testBroadcastSubquery2.result               |    3 +
 .../testComplexJoinCondition5.Hash.plan         |  117 ++
 ...tComplexJoinCondition5.Hash_NoBroadcast.plan |  117 ++
 .../testComplexJoinCondition5.Sort.plan         |  117 ++
 ...tComplexJoinCondition5.Sort_NoBroadcast.plan |  117 ++
 .../testComplexJoinCondition5.result            |   29 +
 .../testComplexJoinCondition6.Hash.plan         |  145 ++
 ...tComplexJoinCondition6.Hash_NoBroadcast.plan |  145 ++
 .../testComplexJoinCondition6.Sort.plan         |  145 ++
 ...tComplexJoinCondition6.Sort_NoBroadcast.plan |  145 ++
 .../testComplexJoinCondition6.result            |   56 +
 .../testComplexJoinCondition7.Hash.plan         |  145 ++
 ...tComplexJoinCondition7.Hash_NoBroadcast.plan |  145 ++
 .../testComplexJoinCondition7.Sort.plan         |  145 ++
 ...tComplexJoinCondition7.Sort_NoBroadcast.plan |  145 ++
 .../testComplexJoinCondition7.result            |   56 +
 .../testJoinWithJson2.result                    |    5 +
 .../testJoinWithMultipleJoinQual2.Hash.plan     |  116 ++
 ...nWithMultipleJoinQual2.Hash_NoBroadcast.plan |  142 ++
 .../testJoinWithMultipleJoinQual2.Sort.plan     |  116 ++
 ...nWithMultipleJoinQual2.Sort_NoBroadcast.plan |  142 ++
 .../testJoinWithMultipleJoinQual2.result        |    3 +
 .../testJoinWithMultipleJoinQual3.Hash.plan     |  138 ++
 ...nWithMultipleJoinQual3.Hash_NoBroadcast.plan |  190 +++
 .../testJoinWithMultipleJoinQual3.Sort.plan     |  138 ++
 ...nWithMultipleJoinQual3.Sort_NoBroadcast.plan |  190 +++
 .../testJoinWithMultipleJoinQual3.result        |    5 +
 .../testJoinWithMultipleJoinQual4.Hash.plan     |  142 ++
 ...nWithMultipleJoinQual4.Hash_NoBroadcast.plan |  194 +++
 .../testJoinWithMultipleJoinQual4.Sort.plan     |  142 ++
 ...nWithMultipleJoinQual4.Sort_NoBroadcast.plan |  194 +++
 .../testJoinWithMultipleJoinQual4.result        |    4 +
 .../testBroadcastBasicJoin.result               |   99 --
 ...estBroadcastMultiColumnPartitionTable.result |    5 -
 ...castMultiColumnPartitionTableInFilter.result |    0
 .../testBroadcastPartitionTable.result          |    5 -
 .../testBroadcastSubquery.result                |   15 -
 .../testBroadcastSubquery2.result               |    3 -
 .../testBroadcastTwoPartJoin.result             |   15 -
 .../TestJoinBroadcast/testCrossJoin.result      |  127 --
 .../testCrossJoinAndCaseWhen.result             |   27 -
 .../testCrossJoinWithAsterisk1.result           |   27 -
 .../testCrossJoinWithAsterisk2.result           |   27 -
 .../testCrossJoinWithAsterisk3.result           |   27 -
 .../testCrossJoinWithAsterisk4.result           |   27 -
 .../testCrossJoinWithEmptyTable1.result         |    2 -
 .../TestJoinBroadcast/testFullOuterJoin1.result |    7 -
 .../testFullOuterJoinWithEmptyTable1.result     |    7 -
 .../testInnerJoinWithEmptyTable.result          |    2 -
 .../testJoinCoReferredEvals1.result             |   27 -
 ...testJoinCoReferredEvalsWithSameExprs1.result |   22 -
 ...testJoinCoReferredEvalsWithSameExprs2.result |   22 -
 .../testJoinOnMultipleDatabases.result          |    5 -
 .../TestJoinBroadcast/testLeftOuterJoin1.result |    7 -
 .../TestJoinBroadcast/testLeftOuterJoin2.result |   99 --
 .../TestJoinBroadcast/testLeftOuterJoin3.result |  174 ---
 .../testLeftOuterJoinWithConstantExpr1.result   |    7 -
 .../testLeftOuterJoinWithConstantExpr2.result   |    7 -
 .../testLeftOuterJoinWithConstantExpr3.result   |    7 -
 .../testLeftOuterJoinWithEmptyTable1.result     |    7 -
 .../testLeftOuterJoinWithEmptyTable2.result     |    7 -
 .../testLeftOuterJoinWithEmptyTable3.result     |    7 -
 .../testLeftOuterJoinWithEmptyTable4.result     |    4 -
 ...ltipleBroadcastDataFileWithZeroLength.result |    2 -
 ...tipleBroadcastDataFileWithZeroLength2.result |  399 ------
 ...tionedBroadcastDataFileWithZeroLength.result |  102 --
 ...ionedBroadcastDataFileWithZeroLength2.result |  399 ------
 .../testOuterJoinAndCaseWhen1.result            |    7 -
 .../testRightOuterJoin1.result                  |    7 -
 .../testRightOuterJoinWithEmptyTable1.result    |    7 -
 .../TestJoinBroadcast/testTPCHQ2Join.result     |    5 -
 .../testWhereClauseJoin1.result                 |   27 -
 .../testWhereClauseJoin2.result                 |   27 -
 .../testWhereClauseJoin3.result                 |   27 -
 .../testWhereClauseJoin4.result                 |   27 -
 .../testWhereClauseJoin5.result                 |    5 -
 .../selfJoinOfPartitionedTable.result           |    2 +-
 .../testBroadcastPartitionTable.result          |    5 +
 ...FilterPushDownPartitionColumnCaseWhen.result |    2 +-
 ...tionedBroadcastDataFileWithZeroLength.result |    7 +
 ...ionedBroadcastDataFileWithZeroLength2.result |    7 +
 .../testNoProjectionJoinQual.result             |    2 +-
 .../testPartialFilterPushDown.result            |    2 +-
 .../testPartialFilterPushDownOuterJoin.result   |    2 +-
 .../testPartialFilterPushDownOuterJoin2.result  |    2 +-
 ...estPartitionMultiplePartitionFilter.1.result |    2 +
 .../testPartitionTableJoinSmallTable.result     |    2 +-
 .../testComplexJoinCondition1.result            |   27 -
 .../testComplexJoinCondition2.result            |   27 -
 .../testComplexJoinCondition3.result            |   27 -
 .../testComplexJoinCondition4.result            |   29 -
 .../testComplexJoinCondition5.result            |   29 -
 .../testComplexJoinCondition6.result            |   56 -
 .../testComplexJoinCondition7.result            |   56 -
 .../testComplexJoinsWithCaseWhen.result         |   27 -
 .../testComplexJoinsWithCaseWhen2.result        |   27 -
 .../results/TestJoinQuery/testCrossJoin.result  |  127 --
 .../testCrossJoinWithAsterisk1.result           |   27 -
 .../testCrossJoinWithAsterisk2.result           |   27 -
 .../testCrossJoinWithAsterisk3.result           |   27 -
 .../testCrossJoinWithAsterisk4.result           |   27 -
 .../testCrossJoinWithEmptyTable1.result         |    2 -
 ...rossJoinWithThetaJoinConditionInWhere.result |   12 -
 .../testDifferentTypesJoinCondition.result      |    7 -
 .../TestJoinQuery/testFullOuterJoin1.result     |    7 -
 .../testFullOuterJoinWithEmptyTable1.result     |    7 -
 .../testInnerJoinAndCaseWhen.result             |   27 -
 .../testInnerJoinWithEmptyTable.result          |    2 -
 ...nnerJoinWithThetaJoinConditionInWhere.result |    7 -
 .../TestJoinQuery/testJoinAsterisk.result       |    7 -
 .../testJoinCoReferredEvals1.result             |   27 -
 ...testJoinCoReferredEvalsWithSameExprs1.result |   22 -
 ...testJoinCoReferredEvalsWithSameExprs2.result |   22 -
 .../testJoinFilterOfRowPreservedTable1.result   |   15 -
 .../testJoinOnMultipleDatabases.result          |    5 -
 .../testJoinOnMultipleDatabasesWithJson.result  |    5 -
 .../TestJoinQuery/testJoinWithJson.result       |   27 -
 .../TestJoinQuery/testJoinWithJson2.result      |    5 -
 .../testJoinWithMultipleJoinQual1.result        |    2 -
 .../testJoinWithMultipleJoinQual2.result        |    3 -
 .../testJoinWithMultipleJoinQual3.result        |    5 -
 .../testJoinWithMultipleJoinQual4.result        |    4 -
 .../testJoinWithMultipleJoinTypes.result        |    6 -
 .../testJoinWithOrPredicates.result             |    4 -
 .../TestJoinQuery/testLeftOuterJoin1.result     |    7 -
 .../testLeftOuterJoinWithConstantExpr1.result   |    7 -
 .../testLeftOuterJoinWithConstantExpr2.result   |    7 -
 .../testLeftOuterJoinWithConstantExpr3.result   |    7 -
 .../testLeftOuterJoinWithConstantExpr4.result   |    7 -
 .../testLeftOuterJoinWithConstantExpr5.result   |    6 -
 .../testLeftOuterJoinWithEmptyTable1.result     |    7 -
 .../testLeftOuterJoinWithEmptyTable2.result     |    7 -
 .../testLeftOuterJoinWithEmptyTable3.result     |    7 -
 .../testLeftOuterJoinWithEmptyTable4.result     |    4 -
 .../testLeftOuterJoinWithEmptyTable5.result     |    4 -
 .../testLeftOuterJoinWithNull1.result           |    4 -
 .../testLeftOuterJoinWithNull2.result           |    4 -
 .../testLeftOuterJoinWithNull3.result           |    2 -
 ...uterJoinWithThetaJoinConditionInWhere.result |    4 -
 .../TestJoinQuery/testNaturalJoin.result        |   27 -
 .../testOuterJoinAndCaseWhen1.result            |    7 -
 .../TestJoinQuery/testRightOuterJoin1.result    |    7 -
 .../testRightOuterJoinWithEmptyTable1.result    |    7 -
 ...uterJoinWithThetaJoinConditionInWhere.result |    4 -
 .../results/TestJoinQuery/testTPCHQ2Join.result |    5 -
 .../TestJoinQuery/testWhereClauseJoin1.result   |   27 -
 .../TestJoinQuery/testWhereClauseJoin2.result   |   27 -
 .../TestJoinQuery/testWhereClauseJoin3.result   |   27 -
 .../TestJoinQuery/testWhereClauseJoin4.result   |   27 -
 .../TestJoinQuery/testWhereClauseJoin5.result   |    5 -
 .../testComplexJoinsWithCaseWhen.Hash.plan      |   98 ++
 ...mplexJoinsWithCaseWhen.Hash_NoBroadcast.plan |  153 +++
 .../testComplexJoinsWithCaseWhen.Sort.plan      |   98 ++
 ...mplexJoinsWithCaseWhen.Sort_NoBroadcast.plan |  153 +++
 .../testComplexJoinsWithCaseWhen.result         |   27 +
 .../testComplexJoinsWithCaseWhen2.Hash.plan     |  138 ++
 ...plexJoinsWithCaseWhen2.Hash_NoBroadcast.plan |  165 +++
 .../testComplexJoinsWithCaseWhen2.Sort.plan     |  138 ++
 ...plexJoinsWithCaseWhen2.Sort_NoBroadcast.plan |  165 +++
 .../testComplexJoinsWithCaseWhen2.result        |   27 +
 .../testInnerAndOuterWithEmpty.1.Hash.plan      |   75 ++
 ...nerAndOuterWithEmpty.1.Hash_NoBroadcast.plan |  130 ++
 .../testInnerAndOuterWithEmpty.1.Sort.plan      |   75 ++
 ...nerAndOuterWithEmpty.1.Sort_NoBroadcast.plan |  130 ++
 .../testInnerAndOuterWithEmpty.1.result         |    7 +
 .../testJoinWithMultipleJoinTypes.Hash.plan     |  140 ++
 ...nWithMultipleJoinTypes.Hash_NoBroadcast.plan |  140 ++
 .../testJoinWithMultipleJoinTypes.Sort.plan     |  140 ++
 ...nWithMultipleJoinTypes.Sort_NoBroadcast.plan |  140 ++
 .../testJoinWithMultipleJoinTypes.result        |    6 +
 .../testFullOuterJoin1.Hash.plan                |   79 ++
 .../testFullOuterJoin1.Hash_NoBroadcast.plan    |  105 ++
 .../testFullOuterJoin1.Sort.plan                |   79 ++
 .../testFullOuterJoin1.Sort_NoBroadcast.plan    |  105 ++
 .../testFullOuterJoin1.result                   |    7 +
 .../testFullOuterJoinWithEmptyTable1.Hash.plan  |   79 ++
 ...terJoinWithEmptyTable1.Hash_NoBroadcast.plan |  105 ++
 .../testFullOuterJoinWithEmptyTable1.Sort.plan  |   79 ++
 ...terJoinWithEmptyTable1.Sort_NoBroadcast.plan |  105 ++
 .../testFullOuterJoinWithEmptyTable1.result     |    7 +
 ...testJoinFilterOfRowPreservedTable1.Hash.plan |   78 ++
 ...erOfRowPreservedTable1.Hash_NoBroadcast.plan |  105 ++
 ...testJoinFilterOfRowPreservedTable1.Sort.plan |   78 ++
 ...erOfRowPreservedTable1.Sort_NoBroadcast.plan |  105 ++
 .../testJoinFilterOfRowPreservedTable1.result   |   15 +
 .../testLeftOuterJoin1.Hash.plan                |   78 ++
 .../testLeftOuterJoin1.Hash_NoBroadcast.plan    |  105 ++
 .../testLeftOuterJoin1.Sort.plan                |   78 ++
 .../testLeftOuterJoin1.Sort_NoBroadcast.plan    |  105 ++
 .../testLeftOuterJoin1.result                   |    7 +
 .../testLeftOuterJoin2.Hash.plan                |   91 ++
 .../testLeftOuterJoin2.Hash_NoBroadcast.plan    |  176 +++
 .../testLeftOuterJoin2.Sort.plan                |   91 ++
 .../testLeftOuterJoin2.Sort_NoBroadcast.plan    |  176 +++
 .../testLeftOuterJoin2.result                   |    7 +
 .../testLeftOuterJoin3.Hash.plan                |  129 ++
 .../testLeftOuterJoin3.Hash_NoBroadcast.plan    |  272 ++++
 .../testLeftOuterJoin3.Sort.plan                |  129 ++
 .../testLeftOuterJoin3.Sort_NoBroadcast.plan    |  272 ++++
 .../testLeftOuterJoin3.result                   |    9 +
 ...tLeftOuterJoinLeftSideSmallTable.1.Hash.plan |  105 ++
 ...inLeftSideSmallTable.1.Hash_NoBroadcast.plan |  105 ++
 ...tLeftOuterJoinLeftSideSmallTable.1.Sort.plan |  105 ++
 ...inLeftSideSmallTable.1.Sort_NoBroadcast.plan |  105 ++
 ...testLeftOuterJoinLeftSideSmallTable.1.result |    7 +
 ...tOuterJoinPredicationCaseByCase1.1.Hash.plan |   72 +
 ...edicationCaseByCase1.1.Hash_NoBroadcast.plan |  128 ++
 ...tOuterJoinPredicationCaseByCase1.1.Sort.plan |   72 +
 ...edicationCaseByCase1.1.Sort_NoBroadcast.plan |  128 ++
 ...LeftOuterJoinPredicationCaseByCase1.1.result |    7 +
 ...tOuterJoinPredicationCaseByCase2.1.Hash.plan |   91 ++
 ...edicationCaseByCase2.1.Hash_NoBroadcast.plan |  176 +++
 ...tOuterJoinPredicationCaseByCase2.1.Sort.plan |   91 ++
 ...edicationCaseByCase2.1.Sort_NoBroadcast.plan |  176 +++
 ...LeftOuterJoinPredicationCaseByCase2.1.result |    4 +
 ...uterJoinPredicationCaseByCase2_1.1.Hash.plan |   98 ++
 ...icationCaseByCase2_1.1.Hash_NoBroadcast.plan |  182 +++
 ...uterJoinPredicationCaseByCase2_1.1.Sort.plan |   98 ++
 ...icationCaseByCase2_1.1.Sort_NoBroadcast.plan |  182 +++
 ...ftOuterJoinPredicationCaseByCase2_1.1.result |    5 +
 ...tOuterJoinPredicationCaseByCase3.1.Hash.plan |   72 +
 ...edicationCaseByCase3.1.Hash_NoBroadcast.plan |  128 ++
 ...tOuterJoinPredicationCaseByCase3.1.Sort.plan |   72 +
 ...edicationCaseByCase3.1.Sort_NoBroadcast.plan |  128 ++
 ...LeftOuterJoinPredicationCaseByCase3.1.result |    7 +
 ...tOuterJoinPredicationCaseByCase4.1.Hash.plan |   74 ++
 ...edicationCaseByCase4.1.Hash_NoBroadcast.plan |  130 ++
 ...tOuterJoinPredicationCaseByCase4.1.Sort.plan |   74 ++
 ...edicationCaseByCase4.1.Sort_NoBroadcast.plan |  130 ++
 ...LeftOuterJoinPredicationCaseByCase4.1.result |    7 +
 ...tOuterJoinPredicationCaseByCase5.1.Hash.plan |   74 ++
 ...edicationCaseByCase5.1.Hash_NoBroadcast.plan |  130 ++
 ...tOuterJoinPredicationCaseByCase5.1.Sort.plan |   74 ++
 ...edicationCaseByCase5.1.Sort_NoBroadcast.plan |  130 ++
 ...LeftOuterJoinPredicationCaseByCase5.1.result |    6 +
 ...tOuterJoinPredicationCaseByCase6.1.Hash.plan |   76 ++
 ...edicationCaseByCase6.1.Hash_NoBroadcast.plan |  132 ++
 ...tOuterJoinPredicationCaseByCase6.1.Sort.plan |   76 ++
 ...edicationCaseByCase6.1.Sort_NoBroadcast.plan |  132 ++
 ...LeftOuterJoinPredicationCaseByCase6.1.result |    3 +
 ...testLeftOuterJoinWithConstantExpr1.Hash.plan |   86 ++
 ...rJoinWithConstantExpr1.Hash_NoBroadcast.plan |  113 ++
 ...testLeftOuterJoinWithConstantExpr1.Sort.plan |   86 ++
 ...rJoinWithConstantExpr1.Sort_NoBroadcast.plan |  113 ++
 .../testLeftOuterJoinWithConstantExpr1.result   |    7 +
 ...testLeftOuterJoinWithConstantExpr4.Hash.plan |   63 +
 ...rJoinWithConstantExpr4.Hash_NoBroadcast.plan |   90 ++
 ...testLeftOuterJoinWithConstantExpr4.Sort.plan |   63 +
 ...rJoinWithConstantExpr4.Sort_NoBroadcast.plan |   90 ++
 .../testLeftOuterJoinWithConstantExpr4.result   |    7 +
 ...testLeftOuterJoinWithConstantExpr5.Hash.plan |   65 +
 ...rJoinWithConstantExpr5.Hash_NoBroadcast.plan |   92 ++
 ...testLeftOuterJoinWithConstantExpr5.Sort.plan |   65 +
 ...rJoinWithConstantExpr5.Sort_NoBroadcast.plan |   92 ++
 .../testLeftOuterJoinWithConstantExpr5.result   |    6 +
 .../testLeftOuterJoinWithEmptyTable1.Hash.plan  |   78 ++
 ...terJoinWithEmptyTable1.Hash_NoBroadcast.plan |  105 ++
 .../testLeftOuterJoinWithEmptyTable1.Sort.plan  |   78 ++
 ...terJoinWithEmptyTable1.Sort_NoBroadcast.plan |  105 ++
 .../testLeftOuterJoinWithEmptyTable1.result     |    7 +
 .../testLeftOuterJoinWithEmptyTable2.Hash.plan  |  109 ++
 ...terJoinWithEmptyTable2.Hash_NoBroadcast.plan |  136 ++
 .../testLeftOuterJoinWithEmptyTable2.Sort.plan  |  109 ++
 ...terJoinWithEmptyTable2.Sort_NoBroadcast.plan |  136 ++
 .../testLeftOuterJoinWithEmptyTable2.result     |    7 +
 .../testLeftOuterJoinWithEmptyTable3.Hash.plan  |  160 +++
 ...terJoinWithEmptyTable3.Hash_NoBroadcast.plan |  187 +++
 .../testLeftOuterJoinWithEmptyTable3.Sort.plan  |  160 +++
 ...terJoinWithEmptyTable3.Sort_NoBroadcast.plan |  187 +++
 .../testLeftOuterJoinWithEmptyTable3.result     |    7 +
 .../testLeftOuterJoinWithEmptyTable4.Hash.plan  |  160 +++
 ...terJoinWithEmptyTable4.Hash_NoBroadcast.plan |  214 +++
 .../testLeftOuterJoinWithEmptyTable4.Sort.plan  |  160 +++
 ...terJoinWithEmptyTable4.Sort_NoBroadcast.plan |  214 +++
 .../testLeftOuterJoinWithEmptyTable4.result     |    4 +
 .../testLeftOuterJoinWithEmptyTable5.Hash.plan  |  109 ++
 ...terJoinWithEmptyTable5.Hash_NoBroadcast.plan |  136 ++
 .../testLeftOuterJoinWithEmptyTable5.Sort.plan  |  109 ++
 ...terJoinWithEmptyTable5.Sort_NoBroadcast.plan |  136 ++
 .../testLeftOuterJoinWithEmptyTable5.result     |    4 +
 .../testLeftOuterJoinWithNull1.Hash.plan        |   82 ++
 ...LeftOuterJoinWithNull1.Hash_NoBroadcast.plan |  109 ++
 .../testLeftOuterJoinWithNull1.Sort.plan        |   82 ++
 ...LeftOuterJoinWithNull1.Sort_NoBroadcast.plan |  109 ++
 .../testLeftOuterJoinWithNull1.result           |    4 +
 .../testLeftOuterJoinWithNull2.Hash.plan        |   82 ++
 ...LeftOuterJoinWithNull2.Hash_NoBroadcast.plan |  109 ++
 .../testLeftOuterJoinWithNull2.Sort.plan        |   82 ++
 ...LeftOuterJoinWithNull2.Sort_NoBroadcast.plan |  109 ++
 .../testLeftOuterJoinWithNull2.result           |    4 +
 .../testLeftOuterJoinWithNull3.Hash.plan        |   82 ++
 ...LeftOuterJoinWithNull3.Hash_NoBroadcast.plan |  109 ++
 .../testLeftOuterJoinWithNull3.Sort.plan        |   82 ++
 ...LeftOuterJoinWithNull3.Sort_NoBroadcast.plan |  109 ++
 .../testLeftOuterJoinWithNull3.result           |    2 +
 ...rJoinWithThetaJoinConditionInWhere.Hash.plan |   57 +
 ...taJoinConditionInWhere.Hash_NoBroadcast.plan |   84 ++
 ...rJoinWithThetaJoinConditionInWhere.Sort.plan |   57 +
 ...taJoinConditionInWhere.Sort_NoBroadcast.plan |   84 ++
 ...uterJoinWithThetaJoinConditionInWhere.result |    4 +
 .../testLeftOuterWithEmptyTable.1.Hash.plan     |   53 +
 ...tOuterWithEmptyTable.1.Hash_NoBroadcast.plan |   80 ++
 .../testLeftOuterWithEmptyTable.1.Sort.plan     |   53 +
 ...tOuterWithEmptyTable.1.Sort_NoBroadcast.plan |   80 ++
 .../testLeftOuterWithEmptyTable.1.result        |    7 +
 ...pleBroadcastDataFileWithZeroLength.Hash.plan |   57 +
 ...DataFileWithZeroLength.Hash_NoBroadcast.plan |   84 ++
 ...pleBroadcastDataFileWithZeroLength.Sort.plan |   57 +
 ...DataFileWithZeroLength.Sort_NoBroadcast.plan |   84 ++
 ...ltipleBroadcastDataFileWithZeroLength.result |    2 +
 ...leBroadcastDataFileWithZeroLength2.Hash.plan |   76 ++
 ...ataFileWithZeroLength2.Hash_NoBroadcast.plan |  132 ++
 ...leBroadcastDataFileWithZeroLength2.Sort.plan |   76 ++
 ...ataFileWithZeroLength2.Sort_NoBroadcast.plan |  132 ++
 ...tipleBroadcastDataFileWithZeroLength2.result |    7 +
 .../testOuterJoinAndCaseWhen1.Hash.plan         |   97 ++
 ...tOuterJoinAndCaseWhen1.Hash_NoBroadcast.plan |  153 +++
 .../testOuterJoinAndCaseWhen1.Sort.plan         |   97 ++
 ...tOuterJoinAndCaseWhen1.Sort_NoBroadcast.plan |  153 +++
 .../testOuterJoinAndCaseWhen1.result            |    7 +
 .../testRightOuterJoin1.Hash.plan               |   78 ++
 .../testRightOuterJoin1.Hash_NoBroadcast.plan   |  105 ++
 .../testRightOuterJoin1.Sort.plan               |   78 ++
 .../testRightOuterJoin1.Sort_NoBroadcast.plan   |  105 ++
 .../testRightOuterJoin1.result                  |    7 +
 .../testRightOuterJoinWithEmptyTable1.Hash.plan |   78 ++
 ...terJoinWithEmptyTable1.Hash_NoBroadcast.plan |  105 ++
 .../testRightOuterJoinWithEmptyTable1.Sort.plan |   78 ++
 ...terJoinWithEmptyTable1.Sort_NoBroadcast.plan |  105 ++
 .../testRightOuterJoinWithEmptyTable1.result    |    7 +
 ...rJoinWithThetaJoinConditionInWhere.Hash.plan |   57 +
 ...taJoinConditionInWhere.Hash_NoBroadcast.plan |   84 ++
 ...rJoinWithThetaJoinConditionInWhere.Sort.plan |   57 +
 ...taJoinConditionInWhere.Sort_NoBroadcast.plan |   84 ++
 ...uterJoinWithThetaJoinConditionInWhere.result |    4 +
 ...terJoinWithEmptyIntermediateData.1.Hash.plan |  108 ++
 ...mptyIntermediateData.1.Hash_NoBroadcast.plan |  108 ++
 ...terJoinWithEmptyIntermediateData.1.Sort.plan |  108 ++
 ...mptyIntermediateData.1.Sort_NoBroadcast.plan |  108 ++
 ...lOuterJoinWithEmptyIntermediateData.1.result |    2 +
 .../testJoinWithDifferentShuffleKey.1.Hash.plan |  199 +++
 ...hDifferentShuffleKey.1.Hash_NoBroadcast.plan |  199 +++
 .../testJoinWithDifferentShuffleKey.1.Sort.plan |  199 +++
 ...hDifferentShuffleKey.1.Sort_NoBroadcast.plan |  199 +++
 .../testJoinWithDifferentShuffleKey.1.result    |    3 +
 ...testLeftOuterJoinWithConstantExpr2.Hash.plan |  125 ++
 ...rJoinWithConstantExpr2.Hash_NoBroadcast.plan |  125 ++
 ...testLeftOuterJoinWithConstantExpr2.Sort.plan |  125 ++
 ...rJoinWithConstantExpr2.Sort_NoBroadcast.plan |  125 ++
 .../testLeftOuterJoinWithConstantExpr2.result   |    7 +
 ...testLeftOuterJoinWithConstantExpr3.Hash.plan |  156 +++
 ...rJoinWithConstantExpr3.Hash_NoBroadcast.plan |  156 +++
 ...testLeftOuterJoinWithConstantExpr3.Sort.plan |  156 +++
 ...rJoinWithConstantExpr3.Sort_NoBroadcast.plan |  156 +++
 .../testLeftOuterJoinWithConstantExpr3.result   |    7 +
 ...tLeftOuterJoinWithEmptySubquery1.1.Hash.plan |  141 ++
 ...inWithEmptySubquery1.1.Hash_NoBroadcast.plan |  167 +++
 ...tLeftOuterJoinWithEmptySubquery1.1.Sort.plan |  141 ++
 ...inWithEmptySubquery1.1.Sort_NoBroadcast.plan |  167 +++
 ...testLeftOuterJoinWithEmptySubquery1.1.result |    7 +
 ...tLeftOuterJoinWithEmptySubquery2.1.Hash.plan |  116 ++
 ...inWithEmptySubquery2.1.Hash_NoBroadcast.plan |  142 ++
 ...tLeftOuterJoinWithEmptySubquery2.1.Sort.plan |  116 ++
 ...inWithEmptySubquery2.1.Sort_NoBroadcast.plan |  142 ++
 ...testLeftOuterJoinWithEmptySubquery2.1.result |    2 +
 .../testExplainSelectPhysical.1.result          |    4 +-
 .../testExplainSelectPhysical.2.result          |   42 +-
 .../testExplainSelectPhysical.3.result          |    4 +-
 675 files changed, 43624 insertions(+), 7159 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ba9daf2..2e9f2c5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,8 @@ Release 0.11.0 - unreleased
 
   IMPROVEMENT
 
+    TAJO-1577: Add test cases to verify join plans. (jihoon)
+
     TAJO-1607: Tajo Rest Cache-Id should be bigger than zero. (Contributed by 
     DaeMyoung Kang, Committed by hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/PartitionMergeScanExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/PartitionMergeScanExec.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/PartitionMergeScanExec.java
index a1eaa48..c1a451a 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/PartitionMergeScanExec.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/PartitionMergeScanExec.java
@@ -64,10 +64,18 @@ public class PartitionMergeScanExec extends ScanExec {
       scanners.add(scanExec);
     }
     progress = 0.0f;
-    rescan();
+    initScanExecutors();
     super.init();
   }
 
+  private void initScanExecutors() throws IOException {
+    if (scanners.size() > 0) {
+      iterator = scanners.iterator();
+      currentScanner = iterator.next();
+      currentScanner.init();
+    }
+  }
+
   @Override
   public Tuple next() throws IOException {
     Tuple tuple;
@@ -78,10 +86,13 @@ public class PartitionMergeScanExec extends ScanExec {
         return tuple;
       }
 
+      // since read tuple is null, close the current scanner.
+      if (currentScanner != null) {
+        currentScanner.close();
+        currentScanner = null;
+      }
+
       if (iterator.hasNext()) {
-        if (currentScanner != null) {
-          currentScanner.close();
-        }
         currentScanner = iterator.next();
         currentScanner.init();
       } else {
@@ -93,11 +104,10 @@ public class PartitionMergeScanExec extends ScanExec {
 
   @Override
   public void rescan() throws IOException {
-    if (scanners.size() > 0) {
-      iterator = scanners.iterator();
-      currentScanner = iterator.next();
-      currentScanner.init();
+    for (SeqScanExec scanner : scanners) {
+      scanner.close();
     }
+    initScanExecutors();
   }
 
   @Override
@@ -110,6 +120,7 @@ public class PartitionMergeScanExec extends ScanExec {
         inputStats.merge(scannerTableStsts);
       }
     }
+    scanners.clear();
     iterator = null;
     progress = 1.0f;
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/SeqScanExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/SeqScanExec.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/SeqScanExec.java
index 2225dae..7c82649 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/SeqScanExec.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/SeqScanExec.java
@@ -269,9 +269,6 @@ public class SeqScanExec extends ScanExec {
       }
     }
     scanner = null;
-    plan = null;
-    qual = null;
-    projector = null;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
index ab37e22..b8574fe 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.master.exec;
 
+import org.apache.hadoop.fs.Path;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.plan.LogicalPlan;
@@ -25,35 +26,41 @@ import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.Target;
 import org.apache.tajo.plan.expr.AlgebraicUtil;
 import org.apache.tajo.plan.expr.EvalNode;
-import org.apache.tajo.plan.logical.JoinNode;
-import org.apache.tajo.plan.logical.LogicalNode;
-import org.apache.tajo.plan.logical.ScanNode;
+import org.apache.tajo.plan.logical.*;
 import org.apache.tajo.plan.util.PlannerUtil;
 import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
+import org.apache.tajo.util.TUtil;
 
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Stack;
+import java.util.*;
 
 /**
  * Tajo's logical planner can generate different shapes of logical plans for the same query,
  * especially when the query involves one or more joins.
- * This class guarantees the consistency of the logical plan for the same query.
+ * This class guarantees the plans' shape determinant.
  */
 public class ExplainPlanPreprocessorForTest {
   private static final PlanShapeFixerContext shapeFixerContext = new PlanShapeFixerContext();
   private static final PlanShapeFixer shapeFixer = new PlanShapeFixer();
-  private static final PidResetContext resetContext = new PidResetContext();
-  private static final PidReseter pidReseter = new PidReseter();
+  private static final PidCollectorContext collectorContext = new PidCollectorContext();
+  private static final JoinPidCollector joinPidCollector = new JoinPidCollector();
+  private static final PidReseterContext resetContext = new PidReseterContext();
+  private static final JoinPidReseter joinPidReseter = new JoinPidReseter();
 
   public void prepareTest(LogicalPlan plan) throws PlanningException {
-    // Pid reseter
-    resetContext.reset();
-    pidReseter.visit(resetContext, plan, plan.getRootBlock());
-
     // Plan shape fixer
     shapeFixerContext.reset();
     shapeFixer.visit(shapeFixerContext, plan, plan.getRootBlock());
+
+    /*
+     * During join order optimization, new join nodes are created based on the chosen join order.
+     * So, they have different pids for each query execution.
+     * JoinPidCollector and JoinPidReseter reset the pids of join nodes.
+     */
+    collectorContext.reset();
+    joinPidCollector.visit(collectorContext, plan, plan.getRootBlock());
+
+    resetContext.reset(collectorContext.joinPids);
+    joinPidReseter.visit(resetContext, plan, plan.getRootBlock());
   }
 
   private static class PlanShapeFixerContext {
@@ -66,7 +73,7 @@ public class ExplainPlanPreprocessorForTest {
 
   /**
    * Given a commutative join, two children of the join node are interchangeable.
-   * This class fix the logical plan according to the following rules.
+   * This class change the logical plan according to the following rules.
    *
    * <h3>Rules</h3>
    * <ul>
@@ -87,7 +94,19 @@ public class ExplainPlanPreprocessorForTest {
     public LogicalNode visit(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
                              LogicalNode node, Stack<LogicalNode> stack) throws PlanningException {
       super.visit(context, plan, block, node, stack);
-      context.childNumbers.push(context.childNumbers.pop()+1);
+      node.setInSchema(sortSchema(node.getInSchema()));
+      node.setOutSchema(sortSchema(node.getOutSchema()));
+      context.childNumbers.push(context.childNumbers.pop() + 1);
+      return null;
+    }
+
+    @Override
+    public LogicalNode visitFilter(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
+                                   SelectionNode node, Stack<LogicalNode> stack) throws PlanningException {
+      super.visitFilter(context, plan, block, node, stack);
+      if (node.hasQual()) {
+        node.setQual(sortQual(node.getQual()));
+      }
       return null;
     }
 
@@ -96,7 +115,28 @@ public class ExplainPlanPreprocessorForTest {
                                  ScanNode node, Stack<LogicalNode> stack) throws PlanningException {
       super.visitScan(context, plan, block, node, stack);
       context.childNumbers.push(1);
-      node.setInSchema(sortSchema(node.getInSchema()));
+      if (node.hasTargets()) {
+        node.setTargets(sortTargets(node.getTargets()));
+      }
+      if (node.hasQual()) {
+        node.setQual(sortQual(node.getQual()));
+      }
+      return null;
+    }
+
+    @Override
+    public LogicalNode visitPartitionedTableScan(PlanShapeFixerContext context, LogicalPlan plan,
+                                                 LogicalPlan.QueryBlock block, PartitionedTableScanNode node,
+                                                 Stack<LogicalNode> stack)
+        throws PlanningException {
+      super.visitPartitionedTableScan(context, plan, block, node, stack);
+      context.childNumbers.push(1);
+      Path[] inputPaths = node.getInputPaths();
+      Arrays.sort(inputPaths);
+      node.setInputPaths(inputPaths);
+      if (node.hasTargets()) {
+        node.setTargets(sortTargets(node.getTargets()));
+      }
       if (node.hasQual()) {
         node.setQual(sortQual(node.getQual()));
       }
@@ -115,24 +155,21 @@ public class ExplainPlanPreprocessorForTest {
         if (leftChildNum < rightChildNum) {
           swapChildren(node);
         } else if (leftChildNum == rightChildNum) {
-          if (node.getLeftChild().toString().compareTo(node.getRightChild().toString()) <
+          if (node.getLeftChild().getOutSchema().toString().compareTo(node.getRightChild().getOutSchema().toString()) <
               0) {
             swapChildren(node);
           }
         }
       }
 
-      node.setInSchema(sortSchema(node.getInSchema()));
-      node.setOutSchema(sortSchema(node.getOutSchema()));
+      if (node.hasTargets()) {
+        node.setTargets(sortTargets(node.getTargets()));
+      }
 
       if (node.hasJoinQual()) {
         node.setJoinQual(sortQual(node.getJoinQual()));
       }
 
-      if (node.hasTargets()) {
-        node.setTargets(sortTargets(node.getTargets()));
-      }
-
       context.childNumbers.push(rightChildNum + leftChildNum);
 
       return null;
@@ -151,6 +188,10 @@ public class ExplainPlanPreprocessorForTest {
 
     private EvalNode sortQual(EvalNode qual) {
       EvalNode[] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(qual);
+      return sortQual(cnf);
+    }
+
+    private EvalNode sortQual(EvalNode[] cnf) {
       Arrays.sort(cnf, evalNodeComparator);
       return AlgebraicUtil.createSingletonExprFromCNF(cnf);
     }
@@ -162,9 +203,6 @@ public class ExplainPlanPreprocessorForTest {
 
     private static void swapChildren(JoinNode node) {
       LogicalNode tmpChild = node.getLeftChild();
-      int tmpId = tmpChild.getPID();
-      tmpChild.setPID(node.getRightChild().getPID());
-      node.getRightChild().setPID(tmpId);
       node.setLeftChild(node.getRightChild());
       node.setRightChild(tmpChild);
     }
@@ -194,24 +232,51 @@ public class ExplainPlanPreprocessorForTest {
     }
   }
 
-  private static class PidResetContext {
-    int seqId = 0;
+  private static class PidCollectorContext {
+    List<Integer> joinPids = TUtil.newList();
     public void reset() {
-      seqId = 0;
+      joinPids.clear();
     }
   }
 
   /**
-   * During join order optimization, new join nodes are created based on the chosen join order.
-   * So, each join node has different pids.
-   * This class sequentially assigns unique pids to all logical nodes.
+   * {@link JoinPidCollector} collects the pids of all join
+   * nodes.
    */
-  private static class PidReseter extends BasicLogicalPlanVisitor<PidResetContext, LogicalNode> {
+  private static class JoinPidCollector extends BasicLogicalPlanVisitor<PidCollectorContext, LogicalNode> {
 
     @Override
-    public void preHook(LogicalPlan plan, LogicalNode node, Stack<LogicalNode> stack, PidResetContext context)
-        throws PlanningException {
-      node.setPID(context.seqId++);
+    public LogicalNode visitJoin(PidCollectorContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
+                                 JoinNode node, Stack<LogicalNode> stack) throws PlanningException {
+      context.joinPids.add(node.getPID());
+      super.visitJoin(context, plan, block, node, stack);
+
+      return null;
+    }
+  }
+
+  private static class PidReseterContext {
+    List<Integer> joinPids;
+
+    public void reset(List<Integer> joinPids) {
+      this.joinPids = joinPids;
+      Collections.sort(this.joinPids);
+    }
+  }
+
+  /**
+   * {@link JoinPidReseter} resets pids of join nodes with the pids collected by {@link JoinPidCollector} in ascending
+   * order while traversing the query plan.
+   */
+  private static class JoinPidReseter extends BasicLogicalPlanVisitor<PidReseterContext, LogicalNode> {
+
+    @Override
+    public LogicalNode visitJoin(PidReseterContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
+                                 JoinNode node, Stack<LogicalNode> stack) throws PlanningException {
+      super.visitJoin(context, plan, block, node, stack);
+      node.setPID(context.joinPids.remove(0));
+      
+      return null;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/NamedTest.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/NamedTest.java b/tajo-core/src/test/java/org/apache/tajo/NamedTest.java
new file mode 100644
index 0000000..f2c1bb7
--- /dev/null
+++ b/tajo-core/src/test/java/org/apache/tajo/NamedTest.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NamedTest {
+  String value();
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java b/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
index 22c3640..8d0ff12 100644
--- a/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
+++ b/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
@@ -57,6 +57,7 @@ import org.junit.runner.Description;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.annotation.Annotation;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -67,6 +68,8 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -186,11 +189,15 @@ public class QueryTestCaseBase {
   private static Set<String> createdTableGlobalSet = new HashSet<String>();
   // queries and results directory corresponding to subclass class.
   protected Path currentQueryPath;
+  protected Path namedQueryPath;
   protected Path currentResultPath;
   protected Path currentDatasetPath;
+  protected Path namedDatasetPath;
 
   protected FileSystem currentResultFS;
 
+  protected final String testParameter;
+
   // for getting a method name
   @Rule public TestName name = new TestName();
 
@@ -223,7 +230,7 @@ public class QueryTestCaseBase {
   public void printTestName() {
     /* protect a travis stalled build */
     System.out.println("Run: " + name.getMethodName() +
-         " Used memory: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
+        " Used memory: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
         / (1024 * 1024)) + "MBytes");
   }
 
@@ -235,11 +242,17 @@ public class QueryTestCaseBase {
     } else {
       this.currentDatabase = getClass().getSimpleName();
     }
+    testParameter = null;
     init();
   }
 
   public QueryTestCaseBase(String currentDatabase) {
+    this(currentDatabase, null);
+  }
+
+  public QueryTestCaseBase(String currentDatabase, String testParameter) {
     this.currentDatabase = currentDatabase;
+    this.testParameter = testParameter;
     init();
   }
 
@@ -248,6 +261,11 @@ public class QueryTestCaseBase {
     currentQueryPath = new Path(queryBasePath, className);
     currentResultPath = new Path(resultBasePath, className);
     currentDatasetPath = new Path(datasetBasePath, className);
+    NamedTest namedTest = getClass().getAnnotation(NamedTest.class);
+    if (namedTest != null) {
+      namedQueryPath = new Path(queryBasePath, namedTest.value());
+      namedDatasetPath = new Path(datasetBasePath, namedTest.value());
+    }
 
     try {
       // if the current database is "default", we don't need create it because it is already prepated at startup time.
@@ -343,9 +361,58 @@ public class QueryTestCaseBase {
 
   @Target({ElementType.METHOD})
   @Retention(RetentionPolicy.RUNTIME)
-  protected static @interface SimpleTest {
-    String[] queries();
-    String[] cleanupTables() default {};
+  protected @interface SimpleTest {
+    String[] prepare() default {};
+    QuerySpec[] queries() default {};
+    String[] cleanup() default {};
+  }
+
+  @Target({ElementType.METHOD})
+  @Retention(RetentionPolicy.RUNTIME)
+  protected @interface QuerySpec {
+    String value();
+    boolean override() default false;
+    Option option() default @Option;
+  }
+
+  @Target({ElementType.METHOD})
+  @Retention(RetentionPolicy.RUNTIME)
+  protected @interface Option {
+    boolean withExplain() default false;
+    boolean withExplainGlobal() default false;
+    boolean parameterized() default false;
+    boolean sort() default false;
+  }
+
+  private static class DummyQuerySpec implements QuerySpec {
+    private final String value;
+    private final Option option;
+    public DummyQuerySpec(String value, Option option) {
+      this.value = value;
+      this.option = option;
+    }
+    public Class<? extends Annotation> annotationType() { return QuerySpec.class; }
+    public String value() { return value; }
+    public boolean override() { return option != null; }
+    public Option option() { return option; }
+  }
+
+  private static class DummyOption implements Option {
+    private final boolean explain;
+    private final boolean withExplainGlobal;
+    private final boolean parameterized;
+    private final boolean sort;
+    public DummyOption(boolean explain, boolean withExplainGlobal, boolean parameterized, boolean sort) {
+      this.explain = explain;
+      this.withExplainGlobal = withExplainGlobal;
+      this.parameterized = parameterized;
+      this.sort = sort;
+    }
+    public Class<? extends Annotation> annotationType() { return Option.class; }
+    public boolean withExplain() { return explain;}
+    public boolean withExplainGlobal() { return withExplainGlobal;}
+    public boolean parameterized() { return parameterized;}
+    public boolean sort() { return sort;}
   }
 
   protected void runSimpleTests() throws Exception {
@@ -355,26 +422,80 @@ public class QueryTestCaseBase {
     if (annotation == null) {
       throw new IllegalStateException("Cannot find test annotation");
     }
-    String[] queries = annotation.queries();
+
+    List<String> prepares = new ArrayList<String>(Arrays.asList(annotation.prepare()));
+    QuerySpec[] queries = annotation.queries();
+    Option defaultOption = method.getAnnotation(Option.class);
+    if (defaultOption == null) {
+      defaultOption = new DummyOption(false, false, false, false);
+    }
+
+    boolean fromFile = false;
+    if (queries.length == 0) {
+      Path queryFilePath = getQueryFilePath(getMethodName() + ".sql");
+      List<ParsedResult> parsedResults = SimpleParser.parseScript(FileUtil.readTextFile(new File(queryFilePath.toUri())));
+      int i = 0;
+      for (; i < parsedResults.size() - 1; i++) {
+        prepares.add(parsedResults.get(i).getStatement());
+      }
+      queries = new QuerySpec[] {new DummyQuerySpec(parsedResults.get(i).getHistoryStatement(), null)};
+      fromFile = true;  // do not append query index to result file
+    }
+    
     try {
+      for (String prepare : prepares) {
+        client.executeQueryAndGetResult(prepare).close();
+      }
       for (int i = 0; i < queries.length; i++) {
-        ResultSet result = client.executeQueryAndGetResult(queries[i]);
-        Path resultPath = StorageUtil.concatPath(
-            currentResultPath, methodName + "." + String.valueOf(i + 1) + ".result");
+        QuerySpec spec = queries[i];
+        Option option = spec.override() ? spec.option() : defaultOption;
+        String prefix = "";
+        testingCluster.getConfiguration().set(TajoConf.ConfVars.$TEST_PLAN_SHAPE_FIX_ENABLED.varname, "true");
+        if (option.withExplain()) {// Enable this option to fix the shape of the generated plans.
+          prefix += resultSetToString(executeString("explain " + spec.value()));
+        }
+        if (option.withExplainGlobal()) {
+          // Enable this option to fix the shape of the generated plans.
+          prefix += resultSetToString(executeString("explain global " + spec.value()));
+        }
+
+        // plan test
+        if (prefix.length() > 0) {
+          String planResultName = methodName + (fromFile ? "" : "." + (i + 1)) +
+              ((option.parameterized() && testParameter != null) ? "." + testParameter : "") + ".plan";
+          Path resultPath = StorageUtil.concatPath(currentResultPath, planResultName);
+          if (currentResultFS.exists(resultPath)) {
+            assertEquals("Plan Verification for: " + (i + 1) + " th test",
+                FileUtil.readTextFromStream(currentResultFS.open(resultPath)), prefix);
+          } else if (prefix.length() > 0) {
+            // If there is no result file expected, create gold files for new tests.
+            FileUtil.writeTextToStream(prefix, currentResultFS.create(resultPath));
+            LOG.info("New test output for " + current.getDisplayName() + " is written to " + resultPath);
+            // should be copied to src directory
+          }
+        }
+
+        testingCluster.getConfiguration().set(TajoConf.ConfVars.$TEST_PLAN_SHAPE_FIX_ENABLED.varname, "false");
+        ResultSet result = client.executeQueryAndGetResult(spec.value());
+
+        // result test
+        String fileName = methodName + (fromFile ? "" : "." + (i + 1)) + ".result";
+        Path resultPath = StorageUtil.concatPath(currentResultPath, fileName);
         if (currentResultFS.exists(resultPath)) {
-          assertEquals("Result Verification for: " + (i+1) + "th test",
-              FileUtil.readTextFromStream(currentResultFS.open(resultPath)), resultSetToString(result).trim());
+          assertEquals("Result Verification for: " + (i + 1) + " th test",
+              FileUtil.readTextFromStream(currentResultFS.open(resultPath)), resultSetToString(result, option.sort()));
         } else if (!isNull(result)) {
           // If there is no result file expected, create gold files for new tests.
-          FileUtil.writeTextToStream(resultSetToString(result).trim(), currentResultFS.create(resultPath));
+          FileUtil.writeTextToStream(resultSetToString(result, option.sort()), currentResultFS.create(resultPath));
           LOG.info("New test output for " + current.getDisplayName() + " is written to " + resultPath);
           // should be copied to src directory
         }
+        result.close();
       }
     } finally {
-      for (String tableName : annotation.cleanupTables()) {
+      for (String cleanup : annotation.cleanup()) {
         try {
-          client.dropTable(tableName);
+          client.executeQueryAndGetResult(cleanup).close();
         } catch (ServiceException e) {
           // ignore
         }
@@ -549,6 +670,10 @@ public class QueryTestCaseBase {
     assertEquals(expectedValue, tableDesc.getMeta().getOption(key));
   }
 
+  public String resultSetToString(ResultSet resultSet) throws SQLException {
+    return resultSetToString(resultSet, false);
+  }
+
   /**
    * It transforms a ResultSet instance to rows represented as strings.
    *
@@ -556,7 +681,7 @@ public class QueryTestCaseBase {
    * @return String
    * @throws SQLException
    */
-  public String resultSetToString(ResultSet resultSet) throws SQLException {
+  public String resultSetToString(ResultSet resultSet, boolean sort) throws SQLException {
     StringBuilder sb = new StringBuilder();
     ResultSetMetaData rsmd = resultSet.getMetaData();
     int numOfColumns = rsmd.getColumnCount();
@@ -568,16 +693,24 @@ public class QueryTestCaseBase {
     }
     sb.append("\n-------------------------------\n");
 
+    List<String> results = new ArrayList<String>();
     while (resultSet.next()) {
+      StringBuilder line = new StringBuilder();
       for (int i = 1; i <= numOfColumns; i++) {
-        if (i > 1) sb.append(",");
+        if (i > 1) line.append(",");
         String columnValue = resultSet.getString(i);
         if (resultSet.wasNull()) {
           columnValue = "null";
         }
-        sb.append(columnValue);
+        line.append(columnValue);
       }
-      sb.append("\n");
+      results.add(line.toString());
+    }
+    if (sort) {
+      Collections.sort(results);
+    }
+    for (String line : results) {
+      sb.append(line).append('\n');
     }
     return sb.toString();
   }
@@ -591,7 +724,17 @@ public class QueryTestCaseBase {
   private Path getQueryFilePath(String fileName) throws IOException {
     Path queryFilePath = StorageUtil.concatPath(currentQueryPath, fileName);
     FileSystem fs = currentQueryPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
-    assertTrue(queryFilePath.toString() + " existence check", fs.exists(queryFilePath));
+    if (!fs.exists(queryFilePath)) {
+      if (namedQueryPath != null) {
+        queryFilePath = StorageUtil.concatPath(namedQueryPath, fileName);
+        fs = namedQueryPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
+        if (!fs.exists(queryFilePath)) {
+          throw new IOException("Cannot find " + fileName + " at " + currentQueryPath + " and " + namedQueryPath);
+        }
+      } else {
+        throw new IOException("Cannot find " + fileName + " at " + currentQueryPath);
+      }
+    }
     return queryFilePath;
   }
 
@@ -605,7 +748,17 @@ public class QueryTestCaseBase {
   private Path getDataSetFile(String fileName) throws IOException {
     Path dataFilePath = StorageUtil.concatPath(currentDatasetPath, fileName);
     FileSystem fs = currentDatasetPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
-    assertTrue(dataFilePath.toString() + " existence check", fs.exists(dataFilePath));
+    if (!fs.exists(dataFilePath)) {
+      if (namedDatasetPath != null) {
+        dataFilePath = StorageUtil.concatPath(namedDatasetPath, fileName);
+        fs = namedDatasetPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
+        if (!fs.exists(dataFilePath)) {
+          throw new IOException("Cannot find " + fileName + " at " + currentQueryPath + " and " + namedQueryPath);
+        }
+      } else {
+        throw new IOException("Cannot find " + fileName + " at " + currentQueryPath + " and " + namedQueryPath);
+      }
+    }
     return dataFilePath;
   }
 
@@ -649,9 +802,7 @@ public class QueryTestCaseBase {
   private List<String> executeDDL(String ddlFileName, @Nullable String dataFileName, boolean isLocalTable,
                                   @Nullable String[] args) throws Exception {
 
-    Path ddlFilePath = new Path(currentQueryPath, ddlFileName);
-    FileSystem fs = ddlFilePath.getFileSystem(conf);
-    assertTrue(ddlFilePath + " existence check", fs.exists(ddlFilePath));
+    Path ddlFilePath = getQueryFilePath(ddlFileName);
 
     String template = FileUtil.readTextFile(new File(ddlFilePath.toUri()));
     String dataFilePath = null;

http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java b/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java
index 59f6da5..fcb9b58 100644
--- a/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java
+++ b/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java
@@ -624,6 +624,17 @@ public class TajoTestingCluster {
     }
   }
 
+  public static TajoClient newTajoClient(TajoTestingCluster util) throws InterruptedException, IOException {
+    while(true) {
+      if(util.getMaster().isMasterRunning()) {
+        break;
+      }
+      Thread.sleep(1000);
+    }
+    TajoConf conf = util.getConfiguration();
+    return new TajoClientImpl(ServiceTrackerFactory.get(conf));
+  }
+
   public static void createTable(String tableName, Schema schema,
                                  KeyValueSet tableOption, String[] tableDatas) throws Exception {
     createTable(tableName, schema, tableOption, tableDatas, 1);
@@ -633,14 +644,7 @@ public class TajoTestingCluster {
                                  KeyValueSet tableOption, String[] tableDatas, int numDataFiles) throws Exception {
     TpchTestBase instance = TpchTestBase.getInstance();
     TajoTestingCluster util = instance.getTestingCluster();
-    while(true) {
-      if(util.getMaster().isMasterRunning()) {
-        break;
-      }
-      Thread.sleep(1000);
-    }
-    TajoConf conf = util.getConfiguration();
-    TajoClient client = new TajoClientImpl(ServiceTrackerFactory.get(conf));
+    TajoClient client = newTajoClient(util);
     try {
       FileSystem fs = util.getDefaultFileSystem();
       Path rootDir = TajoConf.getWarehouseDir(util.getConfiguration());