Program: 25284
Project: 25284
Buggy source:
@Test public void testLightestFactFirst() throws Exception {
  String hqlQuery=rewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,getConf());
  String expected=getExpectedQuery(cubeName,"String_Node_Str",null,null,getWhereForDailyAndHourly2days(cubeName,"String_Node_Str"));
  compareQueries(expected,hqlQuery);
  Configuration conf=getConf();
  conf.setBoolean(CubeQueryConfUtil.FAIL_QUERY_ON_PARTIAL_DATA,true);
  hqlQuery=rewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,conf);
  expected=getExpectedQuery(cubeName,"String_Node_Str",null,null,getWhereForHourly2days("String_Node_Str"));
  compareQueries(expected,hqlQuery);
  conf.setBoolean(CubeQueryConfUtil.LIGHTEST_FACT_FIRST,true);
  conf.setBoolean(CubeQueryConfUtil.ADD_NON_EXISTING_PARTITIONS,true);
  SemanticException th=getSemanticExceptionInRewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,conf);
  Assert.assertEquals(th.getCanonicalErrorMsg().getErrorCode(),ErrorMsg.NO_CANDIDATE_FACT_AVAILABLE.getErrorCode());
  PruneCauses.BriefAndDetailedError pruneCauses=extractPruneCause(th);
  Assert.assertEquals(pruneCauses.getBrief().substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3),CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3));
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").size(),1);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").iterator().next().getCause(),CandidateTablePruneCode.MISSING_PARTITIONS);
  conf.setBoolean(CubeQueryConfUtil.ADD_NON_EXISTING_PARTITIONS,false);
  th=getSemanticExceptionInRewrite("String_Node_Str" + "String_Node_Str" + TWO_DAYS_RANGE,conf);
  Assert.assertEquals(th.getCanonicalErrorMsg().getErrorCode(),ErrorMsg.NO_CANDIDATE_FACT_AVAILABLE.getErrorCode());
  pruneCauses=extractPruneCause(th);
  Assert.assertEquals(pruneCauses.getBrief().substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3),CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3));
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").size(),1);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").iterator().next().getCause(),CandidateTablePruneCode.MISSING_PARTITIONS);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").size(),1);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").iterator().next().getCause(),CandidateTablePruneCode.NO_FACT_UPDATE_PERIODS_FOR_GIVEN_RANGE);
}

Fixed version (ground truth):
@Test public void testLightestFactFirst() throws Exception {
  String hqlQuery=rewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,getConf());
  String expected=getExpectedQuery(cubeName,"String_Node_Str",null,null,getWhereForDailyAndHourly2days(cubeName,"String_Node_Str"));
  compareQueries(expected,hqlQuery);
  Configuration conf=getConf();
  conf.setBoolean(CubeQueryConfUtil.FAIL_QUERY_ON_PARTIAL_DATA,true);
  hqlQuery=rewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,conf);
  expected=getExpectedQuery(cubeName,"String_Node_Str",null,null,getWhereForHourly2days("String_Node_Str"));
  compareQueries(expected,hqlQuery);
  conf.setBoolean(CubeQueryConfUtil.LIGHTEST_FACT_FIRST,true);
  conf.setBoolean(CubeQueryConfUtil.ADD_NON_EXISTING_PARTITIONS,true);
  SemanticException th=getSemanticExceptionInRewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,conf);
  Assert.assertEquals(th.getCanonicalErrorMsg().getErrorCode(),ErrorMsg.NO_CANDIDATE_FACT_AVAILABLE.getErrorCode());
  PruneCauses.BriefAndDetailedError pruneCauses=extractPruneCause(th);
  Assert.assertEquals(pruneCauses.getBrief().substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3),CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3));
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").size(),1);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").iterator().next().getCause(),CandidateTablePruneCode.MISSING_PARTITIONS);
  conf.setBoolean(CubeQueryConfUtil.ADD_NON_EXISTING_PARTITIONS,false);
  th=getSemanticExceptionInRewrite("String_Node_Str" + "String_Node_Str" + twoDaysRange,conf);
  Assert.assertEquals(th.getCanonicalErrorMsg().getErrorCode(),ErrorMsg.NO_CANDIDATE_FACT_AVAILABLE.getErrorCode());
  pruneCauses=extractPruneCause(th);
  Assert.assertEquals(pruneCauses.getBrief().substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3),CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.substring(0,CandidateTablePruneCode.MISSING_PARTITIONS.errorFormat.length() - 3));
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").size(),1);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").iterator().next().getCause(),CandidateTablePruneCode.MISSING_PARTITIONS);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").size(),1);
  Assert.assertEquals(pruneCauses.getDetails().get("String_Node_Str").iterator().next().getCause(),CandidateTablePruneCode.NO_FACT_UPDATE_PERIODS_FOR_GIVEN_RANGE);
}