Program: 25190
Project: 25190
Buggy source:
@Override public String getTimeRangeWhereClause(CubeQueryContext cubeQueryContext,String tableName,Set<FactPartition> rangeParts) throws LensException {
  if (rangeParts.size() == 0) {
    return "String_Node_Str";
  }
  boolean useBetweenOnly=cubeQueryContext.getConf().getBoolean(CubeQueryConfUtil.BETWEEN_ONLY_TIME_RANGE_WRITER,CubeQueryConfUtil.DEFAULT_BETWEEN_ONLY_TIME_RANGE_WRITER);
  StringBuilder partStr=new StringBuilder();
  if (!useBetweenOnly && rangeParts.size() == 1) {
    partStr.append("String_Node_Str");
    String partFilter=TimeRangeUtils.getTimeRangePartitionFilter(rangeParts.iterator().next(),cubeQueryContext,tableName);
    partStr.append(partFilter);
    partStr.append("String_Node_Str");
  }
 else {
    TreeSet<FactPartition> parts=new TreeSet<>();
    FactPartition first=null;
    for (    FactPartition part : rangeParts) {
      if (part.hasContainingPart()) {
        throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),"String_Node_Str");
      }
      if (first == null) {
        first=part;
      }
 else {
        if (!first.getPartCol().equalsIgnoreCase(part.getPartCol())) {
          throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),"String_Node_Str");
        }
        if (!first.getPeriod().equals(part.getPeriod())) {
          throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),"String_Node_Str");
        }
      }
      parts.add(part);
    }
    FactPartition start=parts.first();
    FactPartition end=parts.last();
    String partCol=start.getPartCol();
    if (cubeQueryContext != null && !cubeQueryContext.shouldReplaceTimeDimWithPart()) {
      partCol=cubeQueryContext.getTimeDimOfPartitionColumn(partCol);
    }
    partStr.append("String_Node_Str").append(tableName).append("String_Node_Str").append(partCol).append("String_Node_Str").append(start.getFormattedPartSpec()).append("String_Node_Str").append(end.getFormattedPartSpec()).append("String_Node_Str");
  }
  return partStr.toString();
}

Fixed version (ground truth):
@Override public String getTimeRangeWhereClause(CubeQueryContext cubeQueryContext,String tableName,Set<FactPartition> rangeParts) throws LensException {
  if (rangeParts.size() == 0) {
    return "String_Node_Str";
  }
  boolean useBetweenOnly=cubeQueryContext.getConf().getBoolean(CubeQueryConfUtil.BETWEEN_ONLY_TIME_RANGE_WRITER,CubeQueryConfUtil.DEFAULT_BETWEEN_ONLY_TIME_RANGE_WRITER);
  BoundType startBound=BoundType.valueOf(cubeQueryContext.getConf().get(CubeQueryConfUtil.START_DATE_BOUND_TYPE,CubeQueryConfUtil.DEFAULT_START_BOUND_TYPE));
  BoundType endBound=BoundType.valueOf(cubeQueryContext.getConf().get(CubeQueryConfUtil.END_DATE_BOUND_TYPE,CubeQueryConfUtil.DEFAULT_END_BOUND_TYPE));
  StringBuilder partStr=new StringBuilder();
  if (!useBetweenOnly && rangeParts.size() == 1) {
    partStr.append("String_Node_Str");
    String partFilter=TimeRangeUtils.getTimeRangePartitionFilter(rangeParts.iterator().next(),cubeQueryContext,tableName);
    partStr.append(partFilter);
    partStr.append("String_Node_Str");
  }
 else {
    TreeSet<FactPartition> parts=new TreeSet<>();
    FactPartition first=null;
    for (    FactPartition part : rangeParts) {
      if (part.hasContainingPart()) {
        throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),"String_Node_Str");
      }
      if (first == null) {
        first=part;
      }
 else {
        if (!first.getPartCol().equalsIgnoreCase(part.getPartCol())) {
          throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),"String_Node_Str");
        }
        if (!first.getPeriod().equals(part.getPeriod())) {
          throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),"String_Node_Str");
        }
      }
      parts.add(part);
    }
    FactPartition start=parts.first();
    FactPartition end=parts.last();
    if (startBound.equals(BoundType.OPEN)) {
      start=start.previous();
    }
    if (endBound.equals(BoundType.OPEN)) {
      end=end.next();
    }
    String partCol=start.getPartCol();
    if (cubeQueryContext != null && !cubeQueryContext.shouldReplaceTimeDimWithPart()) {
      partCol=cubeQueryContext.getTimeDimOfPartitionColumn(partCol);
    }
    partStr.append("String_Node_Str").append(tableName).append("String_Node_Str").append(partCol).append("String_Node_Str").append(start.getFormattedPartSpec()).append("String_Node_Str").append(end.getFormattedPartSpec()).append("String_Node_Str");
  }
  return partStr.toString();
}