Program: 138487
Project: 138487
Buggy source:
/** 
 * DOC scorreia Comment method "instantiateQuery".
 * @param indicator
 */
private void instantiateQuery(Indicator indicator){
  if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
    ColumnSetMultiValueIndicator colSetMultValIndicator=(ColumnSetMultiValueIndicator)indicator;
    final EList<ModelElement> analyzedColumns=colSetMultValIndicator.getAnalyzedColumns();
    final EList<String> numericFunctions=initializeNumericFunctions(colSetMultValIndicator);
    final EList<String> dateFunctions=initializeDateFunctions(colSetMultValIndicator);
    List<String> nominalColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNominalColumns()) {
      nominalColumns.add(getQuotedColumnName(column));
    }
    List<String> computedColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNumericColumns()) {
      for (      String f : numericFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    for (    ModelElement column : colSetMultValIndicator.getDateColumns()) {
      for (      String f : dateFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    computedColumns.add(colSetMultValIndicator.getCountAll());
    String selectItems=createSelect(nominalColumns,computedColumns);
    final Expression sqlGenericExpression=dbms().getSqlExpression(indicator.getIndicatorDefinition());
    String grpByClause=createGroupBy(nominalColumns);
    String tableName=getTableName(analyzedColumns);
    String sqlExpr=dbms().fillGenericQueryWithColumnTableAndAlias(sqlGenericExpression.getBody(),selectItems,tableName,grpByClause);
    String stringDataFilter=AnalysisHelper.getStringDataFilter(cachedAnalysis);
    if (stringDataFilter == null) {
      stringDataFilter="String_Node_Str";
    }
    sqlExpr=dbms().addWhereToStatement(sqlExpr,stringDataFilter);
    indicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(sqlGenericExpression.getLanguage(),sqlExpr));
  }
}

Fixed version (ground truth):
/** 
 * DOC scorreia Comment method "instantiateQuery".
 * @param indicator
 */
private void instantiateQuery(Indicator indicator){
  if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
    ColumnSetMultiValueIndicator colSetMultValIndicator=(ColumnSetMultiValueIndicator)indicator;
    final EList<MetadataColumn> analyzedColumns=colSetMultValIndicator.getAnalyzedColumns();
    final EList<String> numericFunctions=initializeNumericFunctions(colSetMultValIndicator);
    final EList<String> dateFunctions=initializeDateFunctions(colSetMultValIndicator);
    List<String> nominalColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNominalColumns()) {
      nominalColumns.add(getQuotedColumnName(column));
    }
    List<String> computedColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNumericColumns()) {
      for (      String f : numericFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    for (    ModelElement column : colSetMultValIndicator.getDateColumns()) {
      for (      String f : dateFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    computedColumns.add(colSetMultValIndicator.getCountAll());
    String selectItems=createSelect(nominalColumns,computedColumns);
    final Expression sqlGenericExpression=dbms().getSqlExpression(indicator.getIndicatorDefinition());
    String grpByClause=createGroupBy(nominalColumns);
    String tableName=getTableName(analyzedColumns);
    String sqlExpr=dbms().fillGenericQueryWithColumnTableAndAlias(sqlGenericExpression.getBody(),selectItems,tableName,grpByClause);
    String stringDataFilter=AnalysisHelper.getStringDataFilter(cachedAnalysis);
    if (stringDataFilter == null) {
      stringDataFilter="String_Node_Str";
    }
    sqlExpr=dbms().addWhereToStatement(sqlExpr,stringDataFilter);
    indicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(sqlGenericExpression.getLanguage(),sqlExpr));
  }
}