nus-yam/ex-repair huggingface dataset:
Program: 25189
Project: 25189
Buggy source:
private ASTNode processAggregate(ASTNode astNode,ASTNode innerSelectAST,AliasDecider aliasDecider,boolean isSelectAst){
  ASTNode innerSelectASTWithoutAlias=MetastoreUtil.copyAST(astNode);
  ASTNode innerSelectExprAST=new ASTNode(new CommonToken(HiveParser.TOK_SELEXPR,"String_Node_Str"));
  innerSelectExprAST.addChild(innerSelectASTWithoutAlias);
  String alias=aliasDecider.decideAlias(astNode);
  ASTNode aliasNode=new ASTNode(new CommonToken(Identifier,alias));
  innerSelectExprAST.addChild(aliasNode);
  innerSelectAST.addChild(innerSelectExprAST);
  ASTNode dotAST=getDotAST(cubeql.getCube().getName(),alias);
  ASTNode outerAST=new ASTNode(new CommonToken(TOK_FUNCTION,"String_Node_Str"));
  outerAST.addChild(new ASTNode(new CommonToken(Identifier,astNode.getChild(0).getText())));
  outerAST.addChild(dotAST);
  (isSelectAst ? innerToOuterSelectASTs : innerToOuterHavingASTs).put(new HashableASTNode(innerSelectASTWithoutAlias),outerAST);
  return outerAST;
}

Fixed version (ground truth):
private ASTNode processAggregate(ASTNode astNode,ASTNode innerSelectAST,AliasDecider aliasDecider,boolean isSelectAst){
  ASTNode innerSelectASTWithoutAlias=MetastoreUtil.copyAST(astNode);
  ASTNode innerSelectExprAST=new ASTNode(new CommonToken(HiveParser.TOK_SELEXPR,"String_Node_Str"));
  innerSelectExprAST.addChild(innerSelectASTWithoutAlias);
  String alias=aliasDecider.decideAlias(astNode);
  ASTNode aliasNode=new ASTNode(new CommonToken(Identifier,alias));
  innerSelectExprAST.addChild(aliasNode);
  innerSelectAST.addChild(innerSelectExprAST);
  ASTNode dotAST=getDotAST(cubeql.getCube().getName(),alias);
  ASTNode outerAST=new ASTNode(new CommonToken(TOK_FUNCTION,"String_Node_Str"));
  outerAST.addChild(new ASTNode(new CommonToken(Identifier,astNode.getChild(0).getText())));
  outerAST.addChild(dotAST);
  HashableASTNode innerAST=new HashableASTNode(innerSelectASTWithoutAlias);
  if (isSelectAst && !innerToOuterSelectASTs.containsKey(innerAST)) {
    innerToOuterSelectASTs.put(innerAST,outerAST);
  }
 else   if (!isSelectAst && !innerToOuterHavingASTs.containsKey(innerAST)) {
    innerToOuterHavingASTs.put(innerAST,outerAST);
  }
  return outerAST;
}
Program: 25192
Project: 25192
Buggy source:
/** 
 * Builds the query.
 * @throws SemanticException
 */
public void buildDruidQuery(Configuration conf,HiveConf hconf) throws SemanticException, LensException {
  analyzeInternal(conf,hconf);
  if (resolveNativeTables) {
    replaceWithUnderlyingStorage(hconf);
  }
  String limit=getLimitClause(ast);
  ArrayList<String> filters=new ArrayList<>();
  getWhereString(whereAST,filters);
  constructQuery(HQLParser.getString(selectAST,HQLParser.AppendMode.DEFAULT),filters,HQLParser.getString(groupByAST,HQLParser.AppendMode.DEFAULT),HQLParser.getString(havingAST,HQLParser.AppendMode.DEFAULT),HQLParser.getString(orderByAST,HQLParser.AppendMode.DEFAULT),limit);
}

Fixed version (ground truth):
/** 
 * Builds the query.
 * @throws SemanticException
 */
public void buildDruidQuery(Configuration conf,HiveConf hconf) throws SemanticException, LensException {
  analyzeInternal(conf,hconf);
  if (resolveNativeTables) {
    replaceWithUnderlyingStorage(hconf);
  }
  String limit=getLimitClause(ast);
  ArrayList<String> filters=new ArrayList<>();
  getWhereString(whereAST,filters);
  String havingTree=null;
  String orderbyTree=null;
  if (isHavingSupported) {
    havingTree=HQLParser.getString(havingAST,HQLParser.AppendMode.DEFAULT);
  }
  if (isOrderBySupported) {
    orderbyTree=HQLParser.getString(orderByAST,HQLParser.AppendMode.DEFAULT);
  }
  constructQuery(HQLParser.getString(selectAST,HQLParser.AppendMode.DEFAULT),filters,HQLParser.getString(groupByAST,HQLParser.AppendMode.DEFAULT),havingTree,orderbyTree,limit);
}
Program: 25193
Project: 25193
Buggy source:
/** 
 * Construct final query using all trees
 * @param selecttree   the selecttree
 * @param whereFilters the wheretree
 * @param groupbytree  the groupbytree
 * @param havingtree   the havingtree
 * @param orderbytree  the orderbytree
 * @param limit        the limit
 */
private void constructQuery(String selecttree,ArrayList<String> whereFilters,String groupbytree,String havingtree,String orderbytree,String limit){
  log.info("String_Node_Str");
  rewrittenQuery.append("String_Node_Str").append(selecttree.replaceAll("String_Node_Str","String_Node_Str")).append("String_Node_Str");
  String factNameAndAlias=getFactNameAlias(fromAST);
  rewrittenQuery.append(factNameAndAlias);
  if (!whereFilters.isEmpty()) {
    rewrittenQuery.append("String_Node_Str").append(StringUtils.join(whereFilters,"String_Node_Str"));
  }
  if (StringUtils.isNotBlank(groupbytree)) {
    rewrittenQuery.append("String_Node_Str").append(groupbytree);
  }
  if (StringUtils.isNotBlank(havingtree)) {
    rewrittenQuery.append("String_Node_Str").append(havingtree);
  }
  if (StringUtils.isNotBlank(orderbytree)) {
    rewrittenQuery.append("String_Node_Str").append(orderbytree);
  }
  if (StringUtils.isNotBlank(limit)) {
    rewrittenQuery.append("String_Node_Str").append(limit);
  }
}

Fixed version (ground truth):
/** 
 * Construct final query using all trees
 * @param selectTree   the selecttree
 * @param whereFilters the wheretree
 * @param groupbyTree  the groupbytree
 * @param havingTree   the havingtree
 * @param orderbyTree  the orderbytree
 * @param limit        the limit
 */
private void constructQuery(String selectTree,ArrayList<String> whereFilters,String groupbyTree,String havingTree,String orderbyTree,String limit){
  log.info("String_Node_Str");
  rewrittenQuery.append("String_Node_Str").append(selectTree.replaceAll("String_Node_Str","String_Node_Str")).append("String_Node_Str");
  String factNameAndAlias=getFactNameAlias(fromAST);
  rewrittenQuery.append(factNameAndAlias);
  if (!whereFilters.isEmpty()) {
    rewrittenQuery.append("String_Node_Str").append(StringUtils.join(whereFilters,"String_Node_Str"));
  }
  if (StringUtils.isNotBlank(groupbyTree)) {
    rewrittenQuery.append("String_Node_Str").append(groupbyTree);
  }
  if (StringUtils.isNotBlank(havingTree)) {
    rewrittenQuery.append("String_Node_Str").append(havingTree);
  }
  if (StringUtils.isNotBlank(orderbyTree)) {
    rewrittenQuery.append("String_Node_Str").append(orderbyTree);
  }
  if (StringUtils.isNotBlank(limit)) {
    rewrittenQuery.append("String_Node_Str").append(limit);
  }
}
Program: 25196
Project: 25196
Buggy source:
private ASTNode transform(CubeQueryContext cubeql,ASTNode parent,ASTNode node,int nodePos) throws LensException {
  if (node == null) {
    return node;
  }
  int nodeType=node.getToken().getType();
  if (!(HQLParser.isAggregateAST(node))) {
    if (nodeType == HiveParser.TOK_TABLE_OR_COL || nodeType == HiveParser.DOT) {
      ASTNode wrapped=wrapAggregate(cubeql,node);
      if (wrapped != node) {
        if (parent != null) {
          parent.setChild(nodePos,wrapped);
          ASTNode sibling=HQLParser.findNodeByPath(parent,Identifier);
          String expr;
          if (sibling != null) {
            expr=HQLParser.getString(parent);
          }
 else {
            expr=HQLParser.getString(wrapped);
          }
          cubeql.addAggregateExpr(expr.trim());
        }
 else {
          return wrapped;
        }
      }
    }
 else {
      for (int i=0; i < node.getChildCount(); i++) {
        transform(cubeql,node,(ASTNode)node.getChild(i),i);
      }
    }
  }
  return node;
}

Fixed version (ground truth):
private ASTNode transform(CubeQueryContext cubeql,ASTNode parent,ASTNode node,int nodePos) throws LensException {
  if (node == null) {
    return node;
  }
  int nodeType=node.getToken().getType();
  if (!(HQLParser.isAggregateAST(node))) {
    if (nodeType == HiveParser.TOK_TABLE_OR_COL || nodeType == HiveParser.DOT) {
      ASTNode wrapped=wrapAggregate(cubeql,node);
      if (wrapped != node) {
        if (parent != null) {
          parent.setChild(nodePos,wrapped);
        }
 else {
          return wrapped;
        }
      }
    }
 else {
      for (int i=0; i < node.getChildCount(); i++) {
        transform(cubeql,node,(ASTNode)node.getChild(i),i);
      }
    }
  }
  return node;
}
Program: 25197
Project: 25197
Buggy source:
static void extractTabAliasForCol(CubeQueryContext cubeql,TrackQueriedColumns tqc) throws LensException {
  Map<String,String> colToTableAlias=cubeql.getColToTableAlias();
  Set<String> columns=tqc.getTblAliasToColumns().get(CubeQueryContext.DEFAULT_TABLE);
  if (columns == null) {
    return;
  }
  for (  String col : columns) {
    boolean inCube=false;
    if (cubeql.getCube() != null) {
      Set<String> cols=cubeql.getCube().getAllFieldNames();
      if (cols.contains(col.toLowerCase())) {
        String cubeAlias=cubeql.getAliasForTableName(cubeql.getCube().getName());
        colToTableAlias.put(col.toLowerCase(),cubeAlias);
        tqc.addColumnsQueried(cubeAlias,col.toLowerCase());
        inCube=true;
      }
    }
    for (    Dimension dim : cubeql.getDimensions()) {
      if (dim.getAllFieldNames().contains(col.toLowerCase())) {
        if (!inCube) {
          String prevDim=colToTableAlias.get(col.toLowerCase());
          if (prevDim != null && !prevDim.equals(dim.getName())) {
            throw new LensException(LensCubeErrorCode.AMBIGOUS_DIM_COLUMN.getLensErrorInfo(),col,prevDim,dim.getName());
          }
          String dimAlias=cubeql.getAliasForTableName(dim.getName());
          colToTableAlias.put(col.toLowerCase(),dimAlias);
          tqc.addColumnsQueried(dimAlias,col.toLowerCase());
        }
 else {
          throw new LensException(LensCubeErrorCode.AMBIGOUS_CUBE_COLUMN.getLensErrorInfo(),col,cubeql.getCube().getName(),dim.getName());
        }
      }
    }
    if (colToTableAlias.get(col.toLowerCase()) == null) {
      throw new LensException(LensCubeErrorCode.COLUMN_NOT_FOUND.getLensErrorInfo(),col);
    }
  }
}

Fixed version (ground truth):
static void extractTabAliasForCol(Map<String,String> colToTableAlias,TrackQueriedColumns tqc) throws LensException {
  Set<String> columns=tqc.getTblAliasToColumns().get(CubeQueryContext.DEFAULT_TABLE);
  if (columns == null) {
    return;
  }
  for (  String col : columns) {
    tqc.addColumnsQueried(colToTableAlias.get(col.toLowerCase()),col.toLowerCase());
    if (colToTableAlias.get(col.toLowerCase()) == null) {
      throw new LensException(LensCubeErrorCode.COLUMN_NOT_FOUND.getLensErrorInfo(),col);
    }
  }
}
Program: 25198
Project: 25198
Buggy source:
@Override public void rewriteContext(CubeQueryContext cubeql) throws LensException {
  Map<String,String> colToTableAlias=cubeql.getColToTableAlias();
  extractTabAliasForCol(cubeql);
  findDimAttributesAndMeasures(cubeql);
  if (colToTableAlias.isEmpty()) {
    return;
  }
  replaceAliases(cubeql.getSelectAST(),0,colToTableAlias);
  replaceAliases(cubeql.getHavingAST(),0,colToTableAlias);
  replaceAliases(cubeql.getOrderByAST(),0,colToTableAlias);
  replaceAliases(cubeql.getGroupByAST(),0,colToTableAlias);
  replaceAliases(cubeql.getWhereAST(),0,colToTableAlias);
  replaceAliases(cubeql.getJoinAST(),0,colToTableAlias);
  AggregateResolver.updateAggregates(cubeql.getSelectAST(),cubeql);
  AggregateResolver.updateAggregates(cubeql.getHavingAST(),cubeql);
  updateAliasMap(cubeql.getSelectAST(),cubeql);
}

Fixed version (ground truth):
@Override public void rewriteContext(CubeQueryContext cubeql) throws LensException {
  Map<String,String> colToTableAlias=cubeql.getColToTableAlias();
  extractTabAliasForCol(cubeql);
  for (  QueriedPhraseContext qur : cubeql.getQueriedPhrases()) {
    extractTabAliasForCol(colToTableAlias,qur);
  }
  findExpressionsAndMeasures(cubeql);
  if (colToTableAlias.isEmpty()) {
    return;
  }
  replaceAliases(cubeql.getSelectAST(),0,colToTableAlias);
  replaceAliases(cubeql.getHavingAST(),0,colToTableAlias);
  replaceAliases(cubeql.getOrderByAST(),0,colToTableAlias);
  replaceAliases(cubeql.getGroupByAST(),0,colToTableAlias);
  replaceAliases(cubeql.getWhereAST(),0,colToTableAlias);
  replaceAliases(cubeql.getJoinAST(),0,colToTableAlias);
}
Program: 25199
Project: 25199
Buggy source:
/** 
 * Update the ASTs to include only the fields queried from this fact, in all the expressions
 * @param cubeql
 * @throws LensException
 */
public void updateASTs(CubeQueryContext cubeql) throws LensException {
  int currentChild=0;
  for (int i=0; i < cubeql.getSelectAST().getChildCount(); i++) {
    ASTNode selectExpr=(ASTNode)this.selectAST.getChild(currentChild);
    Set<String> exprCols=HQLParser.getColsInExpr(cubeql.getAliasForTableName(cubeql.getCube()),selectExpr);
    if (getColumns().containsAll(exprCols)) {
      selectIndices.add(i);
      if (exprCols.isEmpty() || (!containsAny(cubeql.getCube().getMeasureNames(),exprCols))) {
        dimFieldIndices.add(i);
      }
      ASTNode aliasNode=HQLParser.findNodeByPath(selectExpr,Identifier);
      String alias=cubeql.getSelectAlias(i);
      if (aliasNode != null) {
        String queryAlias=aliasNode.getText();
        if (!queryAlias.equals(alias)) {
          ASTNode newAliasNode=new ASTNode(new CommonToken(HiveParser.Identifier,alias));
          this.selectAST.getChild(currentChild).replaceChildren(selectExpr.getChildCount() - 1,selectExpr.getChildCount() - 1,newAliasNode);
        }
      }
 else {
        ASTNode newAliasNode=new ASTNode(new CommonToken(HiveParser.Identifier,alias));
        this.selectAST.getChild(currentChild).addChild(newAliasNode);
      }
    }
 else {
      this.selectAST.deleteChild(currentChild);
      currentChild--;
    }
    currentChild++;
  }
}

Fixed version (ground truth):
/** 
 * Update the ASTs to include only the fields queried from this fact, in all the expressions
 * @param cubeql
 * @throws LensException
 */
public void updateASTs(CubeQueryContext cubeql) throws LensException {
  int currentChild=0;
  for (int i=0; i < cubeql.getSelectAST().getChildCount(); i++) {
    ASTNode selectExpr=(ASTNode)this.selectAST.getChild(currentChild);
    Set<String> exprCols=HQLParser.getColsInExpr(cubeql.getAliasForTableName(cubeql.getCube()),selectExpr);
    if (getColumns().containsAll(exprCols)) {
      selectIndices.add(i);
      if (exprCols.isEmpty() || (!containsAny(cubeql.getCube().getMeasureNames(),exprCols))) {
        dimFieldIndices.add(i);
      }
      ASTNode aliasNode=HQLParser.findNodeByPath(selectExpr,Identifier);
      String alias=cubeql.getSelectPhrases().get(i).getSelectAlias();
      if (aliasNode != null) {
        String queryAlias=aliasNode.getText();
        if (!queryAlias.equals(alias)) {
          ASTNode newAliasNode=new ASTNode(new CommonToken(HiveParser.Identifier,alias));
          this.selectAST.getChild(currentChild).replaceChildren(selectExpr.getChildCount() - 1,selectExpr.getChildCount() - 1,newAliasNode);
        }
      }
 else {
        ASTNode newAliasNode=new ASTNode(new CommonToken(HiveParser.Identifier,alias));
        this.selectAST.getChild(currentChild).addChild(newAliasNode);
      }
    }
 else {
      this.selectAST.deleteChild(currentChild);
      currentChild--;
    }
    currentChild++;
  }
}
Program: 25200
Project: 25200
Buggy source:
public static ASTNode parseExpr(String expr) throws LensException {
  ParseDriver driver=new ParseDriver();
  ASTNode tree;
  try {
    tree=driver.parseExpression(expr);
  }
 catch (  ParseException e) {
    throw new LensException(COULD_NOT_PARSE_EXPRESSION.getLensErrorInfo(),e,e.getMessage());
  }
  return ParseUtils.findRootNonNullToken(tree);
}

Fixed version (ground truth):
public static ASTNode parseExpr(String expr) throws LensException {
  ParseDriver driver=new ParseDriver();
  ASTNode tree;
  try {
    tree=driver.parseExpression(expr);
  }
 catch (  ParseException e) {
    throw new LensException(COULD_NOT_PARSE_EXPRESSION.getLensErrorInfo(),e,expr);
  }
  return ParseUtils.findRootNonNullToken(tree);
}
Program: 25201
Project: 25201
Buggy source:
@Override public HealthStatus getHealthStatus(){
  boolean isHealthy=true;
  StringBuilder details=new StringBuilder();
  if (!this.getServiceState().equals(STATE.STARTED)) {
    details.append("String_Node_Str");
    isHealthy=false;
  }
  if (getTotalFailedQueries() / (float)getTotalAcceptedQueries() > 0.3) {
    details.append("String_Node_Str");
    isHealthy=false;
  }
  if (!isHealthy) {
    log.error(details.toString());
  }
  return isHealthy ? new HealthStatus(true,"String_Node_Str") : new HealthStatus(false,details.toString());
}

Fixed version (ground truth):
@Override public HealthStatus getHealthStatus(){
  boolean isHealthy=true;
  StringBuilder details=new StringBuilder();
  if (!this.getServiceState().equals(STATE.STARTED)) {
    details.append("String_Node_Str");
    isHealthy=false;
  }
  if (!isHealthy) {
    log.error(details.toString());
  }
  return isHealthy ? new HealthStatus(true,"String_Node_Str") : new HealthStatus(false,details.toString());
}
Program: 25202
Project: 25202
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  LensServerTestUtil.createTable("String_Node_Str",target(),RestAPITestUtil.openFooBarSession(target(),defaultMT),defaultMT);
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25203
Project: 25203
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  cubeObjectFactory=new ObjectFactory();
  metastoreService=LensServices.get().getService(CubeMetastoreService.NAME);
  lensSessionId=metastoreService.openSession("String_Node_Str","String_Node_Str",new HashMap<String,String>());
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25204
Project: 25204
Buggy source:
@AfterTest public void tearDown() throws Exception {
  metastoreService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25205
Project: 25205
Buggy source:
@AfterTest public void tearDown() throws Exception {
  LensServerTestUtil.dropTable(TestQueryService.TEST_TABLE,target(),lensSessionId,defaultMT);
  metastoreService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25206
Project: 25206
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  metastoreService=LensServices.get().getService(CubeMetastoreService.NAME);
  lensSessionId=metastoreService.openSession("String_Node_Str","String_Node_Str",new HashMap<String,String>());
  methodMetricsMap=metricsSvc.getMethodMetricsFactory().getMethodMetricsMap();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25207
Project: 25207
Buggy source:
/** 
 * Setup.
 * @throws Exception the exception
 */
@BeforeTest public void setup() throws Exception {
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  service=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(service);
  log.info("String_Node_Str",service);
}

Fixed version (ground truth):
/** 
 * Setup.
 * @throws Exception the exception
 */
@BeforeClass public void setup() throws Exception {
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  service=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(service);
  log.info("String_Node_Str",service);
}
Program: 25208
Project: 25208
Buggy source:
@AfterTest public void tearDown() throws Exception {
  wiser.stop();
  dropTable(TEST_TABLE);
  queryService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25209
Project: 25209
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  wiser=new Wiser();
  wiser.setHostname("String_Node_Str");
  wiser.setPort(25000);
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  Map<String,String> sessionconf=new HashMap<>();
  sessionconf.put("String_Node_Str","String_Node_Str");
  sessionconf.put(LensConfConstants.QUERY_MAIL_NOTIFY,"String_Node_Str");
  sessionconf.put(LensConfConstants.QUERY_RESULT_EMAIL_CC,"String_Node_Str");
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",sessionconf);
  createTable(TEST_TABLE);
  loadData(TEST_TABLE,TestResourceFile.TEST_DATA2_FILE.getValue());
  wiser.start();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25210
Project: 25210
Buggy source:
@AfterTest public void cleanup() throws Exception {
  Path dir=new Path(conf.get(LensConfConstants.RESULT_SET_PARENT_DIR));
  FileSystem fs=dir.getFileSystem(conf);
  fs.delete(dir,true);
}

Fixed version (ground truth):
@AfterClass public void cleanup() throws Exception {
  Path dir=new Path(conf.get(LensConfConstants.RESULT_SET_PARENT_DIR));
  FileSystem fs=dir.getFileSystem(conf);
  fs.delete(dir,true);
}
Program: 25211
Project: 25211
Buggy source:
/** 
 * Test query result purger
 * @throws InterruptedException the interrupted exception
 * @throws IOException          Signals that an I/O exception has occurred.
 */
@BeforeTest public void setUp() throws IOException {
  String resultsetPath="String_Node_Str" + getClass().getSimpleName();
  conf=new Configuration();
  conf.set(LensConfConstants.RESULT_SET_PARENT_DIR,resultsetPath);
  conf.set(LensConfConstants.QUERY_HDFS_OUTPUT_PATH,"String_Node_Str");
  conf.set(LensConfConstants.QUERY_RESULTSET_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.HDFS_OUTPUT_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.RESULTSET_PURGE_INTERVAL_IN_SECONDS,"String_Node_Str");
  createTestFiles();
}

Fixed version (ground truth):
/** 
 * Test query result purger
 * @throws InterruptedException the interrupted exception
 * @throws IOException          Signals that an I/O exception has occurred.
 */
@BeforeClass public void setUp() throws IOException {
  String resultsetPath="String_Node_Str" + getClass().getSimpleName();
  conf=new Configuration();
  conf.set(LensConfConstants.RESULT_SET_PARENT_DIR,resultsetPath);
  conf.set(LensConfConstants.QUERY_HDFS_OUTPUT_PATH,"String_Node_Str");
  conf.set(LensConfConstants.QUERY_RESULTSET_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.HDFS_OUTPUT_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.RESULTSET_PURGE_INTERVAL_IN_SECONDS,"String_Node_Str");
  createTestFiles();
}
Program: 25212
Project: 25212
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  Map<String,String> sessionconf=new HashMap<>();
  sessionconf.put("String_Node_Str","String_Node_Str");
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",sessionconf);
  createTable(TEST_TABLE);
  loadData(TEST_TABLE,TestResourceFile.TEST_DATA2_FILE.getValue());
  createHSQLTableAndLoadData();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25213
Project: 25213
Buggy source:
@AfterTest public void tearDown() throws Exception {
  dropTable(TEST_TABLE);
  queryService.closeSession(lensSessionId);
  for (  LensDriver driver : queryService.getDrivers()) {
    if (driver instanceof HiveDriver) {
      assertFalse(((HiveDriver)driver).hasLensSession(lensSessionId));
    }
  }
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25214
Project: 25214
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",new HashMap<String,String>());
  createTable(testTable,target(),lensSessionId,"String_Node_Str",defaultMT);
  loadDataFromClasspath(testTable,TestResourceFile.TEST_DATA2_FILE.getValue(),target(),lensSessionId,defaultMT);
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25215
Project: 25215
Buggy source:
@AfterTest public void tearDown() throws Exception {
  dropTable(testTable,target(),lensSessionId,defaultMT);
  queryService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25216
Project: 25216
Buggy source:
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
  queryService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25217
Project: 25217
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  savedQueryService=LensServices.get().getService(SavedQueryService.NAME);
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  Map<String,String> sessionconf=Maps.newHashMap();
  sessionconf.put("String_Node_Str","String_Node_Str");
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",sessionconf);
  SessionState.start(new HiveConf());
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25218
Project: 25218
Buggy source:
@BeforeTest public void setup() throws LensException {
  Configuration conf=new Configuration();
  conf.set(LensConfConstants.QUERY_PHASE1_REWRITERS,Rewriter1.class.getName() + "String_Node_Str" + Rewriter2.class.getName());
  rewriter=new UserQueryToCubeQueryRewriter(conf);
}

Fixed version (ground truth):
@BeforeClass public void setup() throws LensException {
  Configuration conf=new Configuration();
  conf.set(LensConfConstants.QUERY_PHASE1_REWRITERS,Rewriter1.class.getName() + "String_Node_Str" + Rewriter2.class.getName());
  rewriter=new UserQueryToCubeQueryRewriter(conf);
}
Program: 25219
Project: 25219
Buggy source:
@BeforeTest public void setUp(){
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  eventService=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(eventService);
  alarmService=LensServices.get().getService(AlarmService.NAME);
  assertNotNull(alarmService);
  eventService.addListenerForType(alarmEventListener,SchedulerAlarmEvent.class);
}

Fixed version (ground truth):
@BeforeClass public void setUp(){
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  eventService=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(eventService);
  alarmService=LensServices.get().getService(AlarmService.NAME);
  assertNotNull(alarmService);
  eventService.addListenerForType(alarmEventListener,SchedulerAlarmEvent.class);
}
Program: 25220
Project: 25220
Buggy source:
@BeforeTest public void setUp() throws Exception {
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  LensServices.get().getLogSegregationContext().setLogSegregationId("String_Node_Str");
  super.setUp();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25221
Project: 25221
Buggy source:
@Override public HealthStatus getHealthStatus(){
  boolean isHealthy=true;
  StringBuilder details=new StringBuilder();
  if (!this.getServiceState().equals(STATE.STARTED)) {
    details.append("String_Node_Str");
    isHealthy=false;
  }
  if (getTotalFailedQueries() / (float)getTotalAcceptedQueries() > 0.3) {
    details.append("String_Node_Str");
    isHealthy=false;
  }
  if (!isHealthy) {
    log.error(details.toString());
  }
  return isHealthy ? new HealthStatus(true,"String_Node_Str") : new HealthStatus(false,details.toString());
}

Fixed version (ground truth):
@Override public HealthStatus getHealthStatus(){
  boolean isHealthy=true;
  StringBuilder details=new StringBuilder();
  if (!this.getServiceState().equals(STATE.STARTED)) {
    details.append("String_Node_Str");
    isHealthy=false;
  }
  if (!isHealthy) {
    log.error(details.toString());
  }
  return isHealthy ? new HealthStatus(true,"String_Node_Str") : new HealthStatus(false,details.toString());
}
Program: 25222
Project: 25222
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  LensServerTestUtil.createTable("String_Node_Str",target(),RestAPITestUtil.openFooBarSession(target(),defaultMT),defaultMT);
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25223
Project: 25223
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  cubeObjectFactory=new ObjectFactory();
  metastoreService=LensServices.get().getService(CubeMetastoreService.NAME);
  lensSessionId=metastoreService.openSession("String_Node_Str","String_Node_Str",new HashMap<String,String>());
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25224
Project: 25224
Buggy source:
@AfterTest public void tearDown() throws Exception {
  metastoreService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25225
Project: 25225
Buggy source:
@AfterTest public void tearDown() throws Exception {
  LensServerTestUtil.dropTable(TestQueryService.TEST_TABLE,target(),lensSessionId,defaultMT);
  metastoreService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25226
Project: 25226
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  metastoreService=LensServices.get().getService(CubeMetastoreService.NAME);
  lensSessionId=metastoreService.openSession("String_Node_Str","String_Node_Str",new HashMap<String,String>());
  methodMetricsMap=metricsSvc.getMethodMetricsFactory().getMethodMetricsMap();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25227
Project: 25227
Buggy source:
/** 
 * Setup.
 * @throws Exception the exception
 */
@BeforeTest public void setup() throws Exception {
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  service=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(service);
  log.info("String_Node_Str",service);
}

Fixed version (ground truth):
/** 
 * Setup.
 * @throws Exception the exception
 */
@BeforeClass public void setup() throws Exception {
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  service=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(service);
  log.info("String_Node_Str",service);
}
Program: 25228
Project: 25228
Buggy source:
@AfterTest public void tearDown() throws Exception {
  wiser.stop();
  dropTable(TEST_TABLE);
  queryService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25229
Project: 25229
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  wiser=new Wiser();
  wiser.setHostname("String_Node_Str");
  wiser.setPort(25000);
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  Map<String,String> sessionconf=new HashMap<>();
  sessionconf.put("String_Node_Str","String_Node_Str");
  sessionconf.put(LensConfConstants.QUERY_MAIL_NOTIFY,"String_Node_Str");
  sessionconf.put(LensConfConstants.QUERY_RESULT_EMAIL_CC,"String_Node_Str");
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",sessionconf);
  createTable(TEST_TABLE);
  loadData(TEST_TABLE,TestResourceFile.TEST_DATA2_FILE.getValue());
  wiser.start();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25230
Project: 25230
Buggy source:
@AfterTest public void cleanup() throws Exception {
  Path dir=new Path(conf.get(LensConfConstants.RESULT_SET_PARENT_DIR));
  FileSystem fs=dir.getFileSystem(conf);
  fs.delete(dir,true);
}

Fixed version (ground truth):
@AfterClass public void cleanup() throws Exception {
  Path dir=new Path(conf.get(LensConfConstants.RESULT_SET_PARENT_DIR));
  FileSystem fs=dir.getFileSystem(conf);
  fs.delete(dir,true);
}
Program: 25231
Project: 25231
Buggy source:
/** 
 * Test query result purger
 * @throws InterruptedException the interrupted exception
 * @throws IOException          Signals that an I/O exception has occurred.
 */
@BeforeTest public void setUp() throws IOException {
  String resultsetPath="String_Node_Str" + getClass().getSimpleName();
  conf=new Configuration();
  conf.set(LensConfConstants.RESULT_SET_PARENT_DIR,resultsetPath);
  conf.set(LensConfConstants.QUERY_HDFS_OUTPUT_PATH,"String_Node_Str");
  conf.set(LensConfConstants.QUERY_RESULTSET_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.HDFS_OUTPUT_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.RESULTSET_PURGE_INTERVAL_IN_SECONDS,"String_Node_Str");
  createTestFiles();
}

Fixed version (ground truth):
/** 
 * Test query result purger
 * @throws InterruptedException the interrupted exception
 * @throws IOException          Signals that an I/O exception has occurred.
 */
@BeforeClass public void setUp() throws IOException {
  String resultsetPath="String_Node_Str" + getClass().getSimpleName();
  conf=new Configuration();
  conf.set(LensConfConstants.RESULT_SET_PARENT_DIR,resultsetPath);
  conf.set(LensConfConstants.QUERY_HDFS_OUTPUT_PATH,"String_Node_Str");
  conf.set(LensConfConstants.QUERY_RESULTSET_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.HDFS_OUTPUT_RETENTION,"String_Node_Str");
  conf.set(LensConfConstants.RESULTSET_PURGE_INTERVAL_IN_SECONDS,"String_Node_Str");
  createTestFiles();
}
Program: 25232
Project: 25232
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  Map<String,String> sessionconf=new HashMap<>();
  sessionconf.put("String_Node_Str","String_Node_Str");
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",sessionconf);
  createTable(TEST_TABLE);
  loadData(TEST_TABLE,TestResourceFile.TEST_DATA2_FILE.getValue());
  createHSQLTableAndLoadData();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25233
Project: 25233
Buggy source:
@AfterTest public void tearDown() throws Exception {
  dropTable(TEST_TABLE);
  queryService.closeSession(lensSessionId);
  for (  LensDriver driver : queryService.getDrivers()) {
    if (driver instanceof HiveDriver) {
      assertFalse(((HiveDriver)driver).hasLensSession(lensSessionId));
    }
  }
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25234
Project: 25234
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",new HashMap<String,String>());
  createTable(testTable,target(),lensSessionId,"String_Node_Str",defaultMT);
  loadDataFromClasspath(testTable,TestResourceFile.TEST_DATA2_FILE.getValue(),target(),lensSessionId,defaultMT);
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25235
Project: 25235
Buggy source:
@AfterTest public void tearDown() throws Exception {
  dropTable(testTable,target(),lensSessionId,defaultMT);
  queryService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25236
Project: 25236
Buggy source:
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
  queryService.closeSession(lensSessionId);
  super.tearDown();
}

Fixed version (ground truth):
@AfterTest public void tearDown() throws Exception {
  super.tearDown();
}
Program: 25237
Project: 25237
Buggy source:
@BeforeTest public void setUp() throws Exception {
  super.setUp();
  savedQueryService=LensServices.get().getService(SavedQueryService.NAME);
  queryService=LensServices.get().getService(QueryExecutionService.NAME);
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  Map<String,String> sessionconf=Maps.newHashMap();
  sessionconf.put("String_Node_Str","String_Node_Str");
  lensSessionId=queryService.openSession("String_Node_Str","String_Node_Str",sessionconf);
  SessionState.start(new HiveConf());
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25238
Project: 25238
Buggy source:
@BeforeTest public void setup() throws LensException {
  Configuration conf=new Configuration();
  conf.set(LensConfConstants.QUERY_PHASE1_REWRITERS,Rewriter1.class.getName() + "String_Node_Str" + Rewriter2.class.getName());
  rewriter=new UserQueryToCubeQueryRewriter(conf);
}

Fixed version (ground truth):
@BeforeClass public void setup() throws LensException {
  Configuration conf=new Configuration();
  conf.set(LensConfConstants.QUERY_PHASE1_REWRITERS,Rewriter1.class.getName() + "String_Node_Str" + Rewriter2.class.getName());
  rewriter=new UserQueryToCubeQueryRewriter(conf);
}
Program: 25239
Project: 25239
Buggy source:
@BeforeTest public void setUp(){
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  eventService=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(eventService);
  alarmService=LensServices.get().getService(AlarmService.NAME);
  assertNotNull(alarmService);
  eventService.addListenerForType(alarmEventListener,SchedulerAlarmEvent.class);
}

Fixed version (ground truth):
@BeforeClass public void setUp(){
  System.setProperty(LensConfConstants.CONFIG_LOCATION,"String_Node_Str");
  LensServices.get().init(LensServerConf.getHiveConf());
  LensServices.get().start();
  eventService=LensServices.get().getService(LensEventService.NAME);
  assertNotNull(eventService);
  alarmService=LensServices.get().getService(AlarmService.NAME);
  assertNotNull(alarmService);
  eventService.addListenerForType(alarmEventListener,SchedulerAlarmEvent.class);
}
Program: 25240
Project: 25240
Buggy source:
@BeforeTest public void setUp() throws Exception {
  metricsSvc=LensServices.get().getService(MetricsService.NAME);
  LensServices.get().getLogSegregationContext().setLogSegregationId("String_Node_Str");
  super.setUp();
}

Fixed version (ground truth):
@BeforeTest public void setUp() throws Exception {
  super.setUp();
}
Program: 25243
Project: 25243
Buggy source:
private ASTNode wrapAggregate(CubeQueryContext cubeql,ASTNode node) throws LensException {
  String tabname=null;
  String colname;
  if (node.getToken().getType() == HiveParser.TOK_TABLE_OR_COL) {
    colname=node.getChild(0).getText();
  }
 else {
    ASTNode tabident=HQLParser.findNodeByPath(node,TOK_TABLE_OR_COL,Identifier);
    ASTNode colIdent=(ASTNode)node.getChild(1);
    colname=colIdent.getText();
    tabname=tabident.getText();
  }
  String msrname=StringUtils.isBlank(tabname) ? colname : tabname + "String_Node_Str" + colname;
  if (cubeql.isCubeMeasure(msrname)) {
    if (cubeql.getQueriedExprs().contains(colname)) {
      String alias=cubeql.getAliasForTableName(cubeql.getCube().getName());
      for (      ASTNode exprNode : cubeql.getExprCtx().getExpressionContext(colname,alias).getAllASTNodes()) {
        transform(cubeql,null,exprNode,0);
      }
      return node;
    }
 else {
      CubeMeasure measure=cubeql.getCube().getMeasureByName(colname);
      String aggregateFn=measure.getAggregate();
      if (StringUtils.isBlank(aggregateFn)) {
        throw new LensException(LensCubeErrorCode.NO_DEFAULT_AGGREGATE.getLensErrorInfo(),colname);
      }
      ASTNode fnroot=new ASTNode(new CommonToken(HiveParser.TOK_FUNCTION));
      ASTNode fnIdentNode=new ASTNode(new CommonToken(HiveParser.Identifier,aggregateFn));
      fnroot.addChild(fnIdentNode);
      fnroot.addChild(node);
      return fnroot;
    }
  }
 else {
    return node;
  }
}

Fixed version (ground truth):
private ASTNode wrapAggregate(CubeQueryContext cubeql,ASTNode node) throws LensException {
  String tabname=null;
  String colname;
  if (node.getToken().getType() == HiveParser.TOK_TABLE_OR_COL) {
    colname=node.getChild(0).getText();
  }
 else {
    ASTNode tabident=HQLParser.findNodeByPath(node,TOK_TABLE_OR_COL,Identifier);
    ASTNode colIdent=(ASTNode)node.getChild(1);
    colname=colIdent.getText().toLowerCase();
    tabname=tabident.getText().toLowerCase();
  }
  String msrname=StringUtils.isBlank(tabname) ? colname : tabname + "String_Node_Str" + colname;
  if (cubeql.isCubeMeasure(msrname)) {
    if (cubeql.getQueriedExprs().contains(colname)) {
      String alias=cubeql.getAliasForTableName(cubeql.getCube().getName());
      for (      ASTNode exprNode : cubeql.getExprCtx().getExpressionContext(colname,alias).getAllASTNodes()) {
        transform(cubeql,null,exprNode,0);
      }
      return node;
    }
 else {
      CubeMeasure measure=cubeql.getCube().getMeasureByName(colname);
      String aggregateFn=measure.getAggregate();
      if (StringUtils.isBlank(aggregateFn)) {
        throw new LensException(LensCubeErrorCode.NO_DEFAULT_AGGREGATE.getLensErrorInfo(),colname);
      }
      ASTNode fnroot=new ASTNode(new CommonToken(HiveParser.TOK_FUNCTION));
      ASTNode fnIdentNode=new ASTNode(new CommonToken(HiveParser.Identifier,aggregateFn));
      fnroot.addChild(fnIdentNode);
      fnroot.addChild(node);
      return fnroot;
    }
  }
 else {
    return node;
  }
}
Program: 25244
Project: 25244
Buggy source:
private void extractColumns(CubeQueryContext cubeql) throws LensException {
  ASTNode selTree=cubeql.getSelectAST();
  if (selTree.getChildCount() == 1) {
    ASTNode star=HQLParser.findNodeByPath(selTree,TOK_SELEXPR,TOK_ALLCOLREF);
    if (star == null) {
      star=HQLParser.findNodeByPath(selTree,TOK_SELEXPR,TOK_FUNCTIONSTAR);
    }
    if (star != null) {
      int starType=star.getToken().getType();
      if (TOK_FUNCTIONSTAR == starType || TOK_ALLCOLREF == starType) {
        throw new LensException(LensCubeErrorCode.ALL_COLUMNS_NOT_SUPPORTED.getLensErrorInfo());
      }
    }
  }
  getColsForSelectTree(cubeql);
  getColsForWhereTree(cubeql);
  getColsForTree(cubeql,cubeql.getJoinAST(),cubeql);
  getColsForTree(cubeql,cubeql.getGroupByAST(),cubeql);
  getColsForTree(cubeql,cubeql.getHavingAST(),cubeql);
  getColsForTree(cubeql,cubeql.getOrderByAST(),cubeql);
  for (  String table : cubeql.getTblAliasToColumns().keySet()) {
    if (!CubeQueryContext.DEFAULT_TABLE.equalsIgnoreCase(table)) {
      if (!cubeql.addQueriedTable(table)) {
        throw new LensException(LensCubeErrorCode.NEITHER_CUBE_NOR_DIMENSION.getLensErrorInfo());
      }
    }
  }
}

Fixed version (ground truth):
private void extractColumns(CubeQueryContext cubeql) throws LensException {
  ASTNode selTree=cubeql.getSelectAST();
  if (selTree.getChildCount() == 1) {
    ASTNode star=HQLParser.findNodeByPath(selTree,TOK_SELEXPR,TOK_ALLCOLREF);
    if (star == null) {
      star=HQLParser.findNodeByPath(selTree,TOK_SELEXPR,TOK_FUNCTIONSTAR);
    }
    if (star != null) {
      int starType=star.getToken().getType();
      if (TOK_FUNCTIONSTAR == starType || TOK_ALLCOLREF == starType) {
        throw new LensException(LensCubeErrorCode.ALL_COLUMNS_NOT_SUPPORTED.getLensErrorInfo());
      }
    }
  }
  getColsForSelectTree(cubeql);
  getColsForWhereTree(cubeql);
  getColsForTree(cubeql,cubeql.getJoinAST(),cubeql,true);
  getColsForTree(cubeql,cubeql.getGroupByAST(),cubeql,true);
  getColsForTree(cubeql,cubeql.getHavingAST(),cubeql,true);
  getColsForTree(cubeql,cubeql.getOrderByAST(),cubeql,true);
  for (  String table : cubeql.getTblAliasToColumns().keySet()) {
    if (!CubeQueryContext.DEFAULT_TABLE.equalsIgnoreCase(table)) {
      if (!cubeql.addQueriedTable(table)) {
        throw new LensException(LensCubeErrorCode.NEITHER_CUBE_NOR_DIMENSION.getLensErrorInfo());
      }
    }
  }
}
Program: 25245
Project: 25245
Buggy source:
@Override public void visit(TreeNode visited){
  ASTNode node=visited.getNode();
  ASTNode parent=null;
  if (visited.getParent() != null) {
    parent=visited.getParent().getNode();
  }
  if (node.getToken().getType() == TOK_TABLE_OR_COL && (parent != null && parent.getToken().getType() != DOT)) {
    ASTNode ident=(ASTNode)node.getChild(0);
    String column=ident.getText().toLowerCase();
    if (cubeql.getExprToAliasMap().values().contains(column)) {
      return;
    }
    tqc.addColumnsQueried(CubeQueryContext.DEFAULT_TABLE,column);
  }
 else   if (node.getToken().getType() == DOT) {
    ASTNode tabident=HQLParser.findNodeByPath(node,TOK_TABLE_OR_COL,Identifier);
    ASTNode colIdent=(ASTNode)node.getChild(1);
    String column=colIdent.getText().toLowerCase();
    String table=tabident.getText().toLowerCase();
    tqc.addColumnsQueried(table,column);
  }
}

Fixed version (ground truth):
@Override public void visit(TreeNode visited){
  ASTNode node=visited.getNode();
  ASTNode parent=null;
  if (visited.getParent() != null) {
    parent=visited.getParent().getNode();
  }
  if (node.getToken().getType() == TOK_TABLE_OR_COL && (parent != null && parent.getToken().getType() != DOT)) {
    ASTNode ident=(ASTNode)node.getChild(0);
    String column=ident.getText().toLowerCase();
    if (skipAliases && cubeql.getExprToAliasMap().values().contains(column)) {
      return;
    }
    tqc.addColumnsQueried(CubeQueryContext.DEFAULT_TABLE,column);
  }
 else   if (node.getToken().getType() == DOT) {
    ASTNode tabident=HQLParser.findNodeByPath(node,TOK_TABLE_OR_COL,Identifier);
    ASTNode colIdent=(ASTNode)node.getChild(1);
    String column=colIdent.getText().toLowerCase();
    String table=tabident.getText().toLowerCase();
    tqc.addColumnsQueried(table,column);
  }
}