Buggy code:
public class TestCubeRewriter extends TestQueryRewrite { private final String cubeName = CubeTestSetup . CubeTestSetup . TEST_CUBE_NAME ; public Configuration getConf ( ) { } @ Test public void testQueryWithNow ( ) throws Exception { } @ Test public void testCandidateTables ( ) throws Exception { } @ Test public void testCubeQuery ( ) throws Exception { } @ Test public void testLightestFactFirst ( ) throws Exception { String hqlQuery = rewrite ( ( ( "cube<seq2seq4repair_space>select" + "<seq2seq4repair_space>SUM(msr2)<seq2seq4repair_space>from<seq2seq4repair_space>testCube<seq2seq4repair_space>where<seq2seq4repair_space>" ) + ( twoDaysRange ) ) , getConf ( ) ) ; String expected = getExpectedQuery ( cubeName , "select<seq2seq4repair_space>sum(testcube.msr2)<seq2seq4repair_space>FROM<seq2seq4repair_space>" , null , null , getWhereForDailyAndHourly2days ( cubeName , "C2_testfact" ) ) ; TestCubeRewriter . compareQueries ( expected , hqlQuery ) ; Configuration conf = getConf ( ) ; conf . setBoolean ( FAIL_QUERY_ON_PARTIAL_DATA , true ) ; hqlQuery = rewrite ( ( ( "select<seq2seq4repair_space>SUM(msr2)<seq2seq4repair_space>from<seq2seq4repair_space>testCube" + "<seq2seq4repair_space>where<seq2seq4repair_space>" ) + ( twoDaysRange ) ) , conf ) ; expected = getExpectedQuery ( cubeName , "select<seq2seq4repair_space>sum(testcube.msr2)<seq2seq4repair_space>FROM<seq2seq4repair_space>" , null , null , getWhereForHourly2days ( "c1_testfact2" ) ) ; TestCubeRewriter . compareQueries ( expected , hqlQuery ) ; conf . setBoolean ( LIGHTEST_FACT_FIRST , true ) ; conf . setBoolean ( ADD_NON_EXISTING_PARTITIONS , true ) ; SemanticException th = getSemanticExceptionInRewrite ( ( ( "select<seq2seq4repair_space>SUM(msr2)<seq2seq4repair_space>from<seq2seq4repair_space>testCube" + "<seq2seq4repair_space>where<seq2seq4repair_space>" ) + ( twoDaysRange ) ) , conf ) ; Assert . assertEquals ( th . getCanonicalErrorMsg ( ) . getErrorCode ( ) , NO_CANDIDATE_FACT_AVAILABLE . getErrorCode ( ) ) ; PruneCauses . BriefAndDetailedError pruneCauses = extractPruneCause ( th ) ; Assert . assertEquals ( pruneCauses . getBrief ( ) . substring ( 0 , ( ( errorFormat . length ( ) ) - 3 ) ) , errorFormat . substring ( 0 , ( ( errorFormat . length ( ) ) - 3 ) ) ) ; Assert . assertEquals ( pruneCauses . getDetails ( ) . get ( "testfact" ) . size ( ) , 1 ) ; Assert . assertEquals ( pruneCauses . getDetails ( ) . get ( "testfact" ) . iterator ( ) . next ( ) . getCause ( ) , MISSING_PARTITIONS ) ; conf . setBoolean ( ADD_NON_EXISTING_PARTITIONS , false ) ; <START_BUG> th = getSemanticExceptionInRewrite ( ( ( "select<seq2seq4repair_space>SUM(msr2)<seq2seq4repair_space>from<seq2seq4repair_space>testCube" + "<seq2seq4repair_space>where<seq2seq4repair_space>" ) + ( TWO_DAYS_RANGE ) ) , conf ) ; <END_BUG> Assert . assertEquals ( th . getCanonicalErrorMsg ( ) . getErrorCode ( ) , NO_CANDIDATE_FACT_AVAILABLE . getErrorCode ( ) ) ; pruneCauses = extractPruneCause ( th ) ; Assert . assertEquals ( pruneCauses . getBrief ( ) . substring ( 0 , ( ( errorFormat . length ( ) ) - 3 ) ) , errorFormat . substring ( 0 , ( ( errorFormat . length ( ) ) - 3 ) ) ) ; Assert . assertEquals ( pruneCauses . getDetails ( ) . get ( "testfact" ) . size ( ) , 1 ) ; Assert . assertEquals ( pruneCauses . getDetails ( ) . get ( "testfact" ) . iterator ( ) . next ( ) . getCause ( ) , MISSING_PARTITIONS ) ; Assert . assertEquals ( pruneCauses . getDetails ( ) . get ( "testfactmonthly" ) . size ( ) , 1 ) ; Assert . assertEquals ( pruneCauses . getDetails ( ) . get ( "testfactmonthly" ) . iterator ( ) . next ( ) . getCause ( ) , NO_FACT_UPDATE_PERIODS_FOR_GIVEN_RANGE ) ; } @ Test public void testDerivedCube ( ) throws ParseException , SemanticException { } @ Test public void testCubeInsert ( ) throws Exception { } static void compareQueries ( String expected , String actual ) { } static void compareContains ( String expected , String actual ) { } @ Test public void testCubeWhereQuery ( ) throws Exception { } @ Test public void testCubeWhereQueryWithMultipleTables ( ) throws Exception { } @ Test public void testCubeWhereQueryWithMultipleTablesForMonth ( ) throws Exception { } @ Test public void testCubeJoinQuery ( ) throws Exception { } @ Test public void testCubeGroupbyWithConstantProjected ( ) throws Exception { } @ Test public void testCubeGroupbyQuery ( ) throws Exception { } @ Test public void testSelectExprPromotionToGroupByWithSpacesInDimensionAliasAndWithAsKeywordBwColAndAlias ( ) throws ParseException , SemanticException { } @ Test public void testSelectExprPromotionToGroupByWithSpacesInDimensionAliasAndWithoutAsKeywordBwColAndAlias ( ) throws ParseException , SemanticException { } @ Test public void testCubeQueryWithAilas ( ) throws Exception { } @ Test public void testCubeWhereQueryForMonth ( ) throws Exception { } @ Test public void testCubeWhereQueryForMonthWithNoPartialData ( ) throws Exception { } @ Test public void testCubeWhereQueryForMonthUptoMonths ( ) throws Exception { } @ Test public void testDimensionQueryWithMultipleStorages ( ) throws Exception { } @ Test public void testLimitQueryOnDimension ( ) throws Exception { } @ Test public void testColumnAmbiguity ( ) throws Exception { } @ Test public void testAliasReplacer ( ) throws Exception { } @ Test public void testFactsWithInvalidColumns ( ) throws Exception { } @ Test public void testFactsWithTimedDimension ( ) throws Exception { } public void testCubeQueryTimedDimensionFilter ( ) throws Exception { } @ Test public void testFactsWithTimedDimensionWithProcessTimeCol ( ) throws Exception { } @ Test public void testCubeQueryWithMultipleRanges ( ) throws Exception { } @ Test public void testDistinctColWithoutAlias ( ) throws Exception { } @ Test public void testJoinWithMultipleAliases ( ) throws Exception { } @ Test public void testJoinPathColumnLifeValidation ( ) throws Exception { } @ Test public void testCubeQueryWithSpaceInAlias ( ) throws Exception { } @ Test public void testTimeDimensionAndPartCol ( ) throws Exception { } @ Test public void testAliasNameSameAsColumnName ( ) throws Exception { } @ Test public void testDimAttributeQueryWithFact ( ) throws Exception { } @ Test public void testSelectDimonlyJoinOnCube ( ) throws Exception { } @ Test public void testInTimeRangeWriterWithHQL ( ) throws Exception { } private CommandProcessorResponse runExplain ( String hql , HiveConf conf ) throws Exception { } }

Fix:
th = getSemanticExceptionInRewrite ( ( ( "select<seq2seq4repair_space>SUM(msr2)<seq2seq4repair_space>from<seq2seq4repair_space>testCube" + "<seq2seq4repair_space>where<seq2seq4repair_space>" ) + ( twoDaysRange ) ) , conf ) ;