Program: 25194
Project: 25194
Buggy source:
public String rewrite(ASTNode currNode,Configuration conf,HiveConf metastoreConf,boolean resolveNativeTables) throws LensException {
  this.resolveNativeTables=resolveNativeTables;
  rewrittenQuery.setLength(0);
  reset();
  this.ast=currNode;
  ASTNode fromNode=HQLParser.findNodeByPath(currNode,TOK_FROM);
  if (fromNode != null) {
    if (fromNode.getChild(0).getType() == TOK_SUBQUERY) {
      log.warn("String_Node_Str",this,this.query);
      throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
    }
 else     if (isOfTypeJoin(fromNode.getChild(0).getType())) {
      log.warn("String_Node_Str",this,this.query);
      throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
    }
  }
  if (currNode.getToken().getType() == TOK_UNIONALL) {
    log.warn("String_Node_Str",this,this.query);
    throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
  }
  String rewritternQueryText=rewrittenQuery.toString();
  if (currNode.getToken().getType() == TOK_QUERY) {
    try {
      buildDruidQuery(conf,metastoreConf);
      rewritternQueryText=rewrittenQuery.toString();
      log.info("String_Node_Str" + rewritternQueryText);
    }
 catch (    SemanticException e) {
      throw new LensException(e);
    }
  }
  return rewritternQueryText;
}

Fixed version (ground truth):
public String rewrite(ASTNode currNode,Configuration conf,HiveConf metastoreConf,boolean resolveNativeTables) throws LensException {
  this.resolveNativeTables=resolveNativeTables;
  rewrittenQuery.setLength(0);
  reset();
  this.ast=currNode;
  isHavingSupported=conf.getBoolean(JDBCDriverConfConstants.JDBC_IS_HAVING_SUPPORTED,JDBCDriverConfConstants.DEFAULT_JDBC_IS_HAVING_SUPPORTED);
  isOrderBySupported=conf.getBoolean(JDBCDriverConfConstants.JDBC_IS_ORDERBY_SUPPORTED,JDBCDriverConfConstants.DEFAULT_JDBC_IS_ORDERBY_SUPPORTED);
  ASTNode fromNode=HQLParser.findNodeByPath(currNode,TOK_FROM);
  if (fromNode != null) {
    if (fromNode.getChild(0).getType() == TOK_SUBQUERY) {
      log.warn("String_Node_Str",this,this.query);
      throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
    }
 else     if (isOfTypeJoin(fromNode.getChild(0).getType())) {
      log.warn("String_Node_Str",this,this.query);
      throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
    }
  }
  if (currNode.getToken().getType() == TOK_UNIONALL) {
    log.warn("String_Node_Str",this,this.query);
    throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
  }
  if (!isHavingSupported && HQLParser.findNodeByPath(currNode,HiveParser.TOK_INSERT,HiveParser.TOK_HAVING) != null) {
    log.warn("String_Node_Str",this,this.query);
    throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
  }
  if (!isOrderBySupported && HQLParser.findNodeByPath(currNode,HiveParser.TOK_INSERT,HiveParser.TOK_ORDERBY) != null) {
    log.warn("String_Node_Str",this,this.query);
    throw new LensException("String_Node_Str" + this + "String_Node_Str"+ this.query);
  }
  String rewritternQueryText=rewrittenQuery.toString();
  if (currNode.getToken().getType() == TOK_QUERY) {
    try {
      buildDruidQuery(conf,metastoreConf);
      rewritternQueryText=rewrittenQuery.toString();
      log.info("String_Node_Str" + rewritternQueryText);
    }
 catch (    SemanticException e) {
      throw new LensException(e);
    }
  }
  return rewritternQueryText;
}