Buggy code:
public class TestJoinOrderAlgorithm { private static TajoTestingCluster util ; private static CatalogService catalog ; private static SQLAnalyzer sqlAnalyzer ; private static LogicalPlanner planner ; private static LogicalOptimizer optimizer ; private static QueryContext defaultContext ; @ BeforeClass public static void setUp ( ) throws Exception { TestJoinOrderAlgorithm . util = new TajoTestingCluster ( ) ; TestJoinOrderAlgorithm . util . startCatalogCluster ( ) ; TestJoinOrderAlgorithm . catalog = TestJoinOrderAlgorithm . util . getMiniCatalogCluster ( ) . getCatalog ( ) ; TestJoinOrderAlgorithm . catalog . createTablespace ( TajoConstants . DEFAULT_TABLESPACE_NAME , "hdfs:////localhost:1234//warehouse" ) ; TestJoinOrderAlgorithm . catalog . createDatabase ( TajoConstants . DEFAULT_DATABASE_NAME , TajoConstants . DEFAULT_TABLESPACE_NAME ) ; for ( FunctionDesc funcDesc : FunctionLoader . findLegacyFunctions ( ) ) { TestJoinOrderAlgorithm . catalog . createFunction ( funcDesc ) ; } Schema schema = new Schema ( ) ; schema . addColumn ( "name" , TEXT ) ; schema . addColumn ( "empid" , INT4 ) ; schema . addColumn ( "deptname" , TEXT ) ; Schema schema2 = new Schema ( ) ; schema2 . addColumn ( "deptname" , TEXT ) ; schema2 . addColumn ( "manager" , TEXT ) ; Schema schema3 = new Schema ( ) ; schema3 . addColumn ( "deptname" , TEXT ) ; schema3 . addColumn ( "score" , INT4 ) ; schema3 . addColumn ( "phone" , INT4 ) ; TableMeta meta = CatalogUtil . newTableMeta ( "TEXT" ) ; TableDesc people = new TableDesc ( CatalogUtil . buildFQName ( DEFAULT_DATABASE_NAME , "employee" ) , schema , meta , CommonTestingUtil . getTestDir ( ) . toUri ( ) ) ; TestJoinOrderAlgorithm . catalog . createTable ( people ) ; TableDesc student = new TableDesc ( CatalogUtil . buildFQName ( TajoConstants . DEFAULT_DATABASE_NAME , "dept" ) , schema2 , "TEXT" , new KeyValueSet ( ) , CommonTestingUtil . getTestDir ( ) . toUri ( ) ) ; TestJoinOrderAlgorithm . catalog . createTable ( student ) ; TableDesc score = new TableDesc ( CatalogUtil . buildFQName ( TajoConstants . DEFAULT_DATABASE_NAME , "score" ) , schema3 , "TEXT" , new KeyValueSet ( ) , CommonTestingUtil . getTestDir ( ) . toUri ( ) ) ; TestJoinOrderAlgorithm . catalog . createTable ( score ) ; Schema schema4 = new Schema ( ) ; schema4 . addColumn ( "deptname" , TEXT ) ; schema4 . addColumn ( "manager" , TEXT ) ; TableMeta largeTableMeta = CatalogUtil . newTableMeta ( "FAKEFILE" ) ; TableDesc largeDept ; TableStats largeTableStats ; FileSystem fs = FileSystem . getLocal ( TestJoinOrderAlgorithm . util . getConfiguration ( ) ) ; for ( int i = 0 ; i < 6 ; i ++ ) { Path tablePath = new Path ( CommonTestingUtil . getTestDir ( ) , ( "" + ( i + 1 ) ) ) ; fs . create ( tablePath ) ; largeDept = new TableDesc ( CatalogUtil . buildFQName ( TajoConstants . DEFAULT_DATABASE_NAME , ( "large_dept" + ( i + 1 ) ) ) , schema4 , largeTableMeta , tablePath . toUri ( ) ) ; largeTableStats = new TableStats ( ) ; largeTableStats . setNumBytes ( ( ( StorageUnit . PB ) * ( i + 1 ) ) ) ; largeDept . setStats ( largeTableStats ) ; TestJoinOrderAlgorithm . catalog . createTable ( largeDept ) ; } TestJoinOrderAlgorithm . sqlAnalyzer = new SQLAnalyzer ( ) ; TestJoinOrderAlgorithm . planner = new LogicalPlanner ( TestJoinOrderAlgorithm . catalog , TablespaceManager . getInstance ( ) ) ; <START_BUG> TestJoinOrderAlgorithm . optimizer = new LogicalOptimizer ( TestJoinOrderAlgorithm . util . getConfiguration ( ) ) ; <END_BUG> TestJoinOrderAlgorithm . defaultContext = LocalTajoTestingUtility . createDummyContext ( TestJoinOrderAlgorithm . util . getConfiguration ( ) ) ; } @ AfterClass public static void tearDown ( ) throws Exception { } @ Test public final void testCheckingInfinityJoinScore ( ) throws Exception { } private void assertJoinNode ( LogicalNode node , String left , String right ) { } }

Fix:
TestJoinOrderAlgorithm . optimizer = new LogicalOptimizer ( TestJoinOrderAlgorithm . util . getConfiguration ( ) , TestJoinOrderAlgorithm . catalog ) ;