Buggy code:
public class TestBSTIndexExec { private TajoConf conf ; private Path idxPath ; private CatalogService catalog ; private SQLAnalyzer analyzer ; private LogicalPlanner planner ; private LogicalOptimizer optimizer ; private FileTablespace sm ; private Schema idxSchema ; private BaseTupleComparator comp ; private BSTIndexWriter writer ; private HashMap < Integer , Integer > randomValues ; private int rndKey = - 1 ; private FileSystem fs ; private TableMeta meta ; private Path tablePath ; private Random rnd = new Random ( System . currentTimeMillis ( ) ) ; private TajoTestingCluster util ; @ Before public void setup ( ) throws Exception { this . randomValues = new HashMap < Integer , Integer > ( ) ; this . conf = new TajoConf ( ) ; util = new TajoTestingCluster ( ) ; util . startCatalogCluster ( ) ; catalog = util . getMiniCatalogCluster ( ) . getCatalog ( ) ; Path workDir = CommonTestingUtil . getTestDir ( ) ; catalog . createTablespace ( TajoConstants . DEFAULT_TABLESPACE_NAME , workDir . toUri ( ) . toString ( ) ) ; catalog . createDatabase ( DEFAULT_DATABASE_NAME , TajoConstants . DEFAULT_TABLESPACE_NAME ) ; sm = TablespaceManager . getLocalFs ( ) ; idxPath = new Path ( workDir , "test.idx" ) ; Schema schema = new Schema ( ) ; schema . addColumn ( "managerid" , INT4 ) ; schema . addColumn ( "empid" , INT4 ) ; schema . addColumn ( "deptname" , TEXT ) ; this . idxSchema = new Schema ( ) ; idxSchema . addColumn ( "managerid" , INT4 ) ; SortSpec [ ] sortKeys = new SortSpec [ 1 ] ; sortKeys [ 0 ] = new SortSpec ( idxSchema . getColumn ( "managerid" ) , true , false ) ; this . comp = new BaseTupleComparator ( idxSchema , sortKeys ) ; this . writer = new org . apache . tajo . storage . index . bst . BSTIndex ( conf ) . getIndexWriter ( idxPath , TWO_LEVEL_INDEX , this . idxSchema , this . comp ) ; writer . setLoadNum ( 100 ) ; writer . open ( ) ; long offset ; meta = CatalogUtil . newTableMeta ( "CSV" ) ; tablePath = StorageUtil . concatPath ( workDir , "employee" , "table.csv" ) ; fs = tablePath . getFileSystem ( conf ) ; fs . mkdirs ( tablePath . getParent ( ) ) ; FileAppender appender = ( ( FileAppender ) ( sm . getAppender ( meta , schema , tablePath ) ) ) ; appender . init ( ) ; VTuple tuple = new VTuple ( schema . size ( ) ) ; for ( int i = 0 ; i < 10000 ; i ++ ) { VTuple key = new VTuple ( this . idxSchema . size ( ) ) ; int rndKey = rnd . nextInt ( 250 ) ; if ( this . randomValues . containsKey ( rndKey ) ) { int t = ( this . randomValues . remove ( rndKey ) ) + 1 ; this . randomValues . put ( rndKey , t ) ; } else { this . randomValues . put ( rndKey , 1 ) ; } key . put ( new Datum [ ] { DatumFactory . createInt4 ( rndKey ) } ) ; tuple . put ( new Datum [ ] { DatumFactory . createInt4 ( rndKey ) , DatumFactory . createInt4 ( rnd . nextInt ( 10 ) ) , DatumFactory . createText ( ( "dept_" + ( rnd . nextInt ( 10 ) ) ) ) } ) ; offset = appender . getOffset ( ) ; appender . addTuple ( tuple ) ; writer . write ( key , offset ) ; } appender . flush ( ) ; appender . close ( ) ; writer . close ( ) ; <START_BUG> TableDesc desc = new TableDesc ( CatalogUtil . buildFQName ( DEFAULT_DATABASE_NAME , "employee" ) , schema , meta , sm . getTableUri ( DEFAULT_DATABASE_NAME , "employee" ) ) ; <END_BUG> catalog . createTable ( desc ) ; analyzer = new SQLAnalyzer ( ) ; planner = new LogicalPlanner ( catalog , TablespaceManager . getInstance ( ) ) ; optimizer = new LogicalOptimizer ( conf ) ; } @ After public void tearDown ( ) { } @ Test public void testEqual ( ) throws Exception { } private class TmpPlanner extends PhysicalPlannerImpl { public TmpPlanner ( TajoConf conf ) { } @ Override public PhysicalExec createScanPlan ( TaskAttemptContext ctx , ScanNode scanNode , Stack < LogicalNode > stack ) throws IOException { } } No newline ; at end ; of file ; }

Fix:
TableDesc desc = new TableDesc ( CatalogUtil . buildFQName ( DEFAULT_DATABASE_NAME , "employee" ) , schema , meta , tablePath . toUri ( ) ) ;