Source:
<code>private QueryState finalizeQuery(Query query, QueryCompletedEvent event) { Stage lastStage = query.getStage(event.getExecutionBlockId()); try { LogicalRootNode rootNode = lastStage.getMasterPlan().getLogicalPlan().getRootBlock().getRoot(); CatalogService catalog = lastStage.getContext().getQueryMasterContext().getWorkerContext().getCatalog(); TableDesc tableDesc = PlannerUtil.getTableDesc(catalog, rootNode.getChild()); QueryContext queryContext = query.context.getQueryContext(); Tablespace space = TablespaceManager.get(queryContext.get(QueryVars.OUTPUT_TABLE_URI, "")).get(); Path finalOutputDir = space.commitTable( query.context.getQueryContext(), lastStage.getId(), lastStage.getMasterPlan().getLogicalPlan(), lastStage.getSchema(), tableDesc); QueryHookExecutor hookExecutor = new QueryHookExecutor(query.context.getQueryMasterContext()); hookExecutor.execute(query.context.getQueryContext(), query, event.getExecutionBlockId(), finalOutputDir); if (queryContext.hasOutputTableUri() && queryContext.hasPartition()) { Set<PartitionDescProto> partitions = query.getPartitions(); if (partitions != null) { String databaseName, simpleTableName; if (CatalogUtil.isFQTableName(tableDesc.getName())) { String[] split = CatalogUtil.splitFQTableName(tableDesc.getName()); databaseName = split[0]; simpleTableName = split[1]; } else { databaseName = queryContext.getCurrentDatabase(); simpleTableName = tableDesc.getName(); } catalog.addPartitions(databaseName, simpleTableName, TUtil.newList(partitions), true); LOG.info("Added partitions to catalog (total=" + partitions.size() + ")"); } else { LOG.info("Can't find partitions for adding."); } query.clearPartitions(); <START> partitions.clear(); <END> } } catch (Throwable e) { query.eventHandler.handle(new QueryDiagnosticsUpdateEvent(query.id, ExceptionUtils.getStackTrace(e))); return QueryState.QUERY_ERROR; } return QueryState.QUERY_SUCCEEDED; }</code><technical_language>please remove unnecessary code</technical_language>

Target:
private QueryState finalizeQuery(Query query, QueryCompletedEvent event) { Stage lastStage = query.getStage(event.getExecutionBlockId()); try { LogicalRootNode rootNode = lastStage.getMasterPlan().getLogicalPlan().getRootBlock().getRoot(); CatalogService catalog = lastStage.getContext().getQueryMasterContext().getWorkerContext().getCatalog(); TableDesc tableDesc = PlannerUtil.getTableDesc(catalog, rootNode.getChild()); QueryContext queryContext = query.context.getQueryContext(); Tablespace space = TablespaceManager.get(queryContext.get(QueryVars.OUTPUT_TABLE_URI, "")).get(); Path finalOutputDir = space.commitTable( query.context.getQueryContext(), lastStage.getId(), lastStage.getMasterPlan().getLogicalPlan(), lastStage.getSchema(), tableDesc); QueryHookExecutor hookExecutor = new QueryHookExecutor(query.context.getQueryMasterContext()); hookExecutor.execute(query.context.getQueryContext(), query, event.getExecutionBlockId(), finalOutputDir); if (queryContext.hasOutputTableUri() && queryContext.hasPartition()) { List<PartitionDescProto> partitions = query.getPartitions(); if (partitions != null) { String databaseName, simpleTableName; if (CatalogUtil.isFQTableName(tableDesc.getName())) { String[] split = CatalogUtil.splitFQTableName(tableDesc.getName()); databaseName = split[0]; simpleTableName = split[1]; } else { databaseName = queryContext.getCurrentDatabase(); simpleTableName = tableDesc.getName(); } catalog.addPartitions(databaseName, simpleTableName, partitions, true); LOG.info("Added partitions to catalog (total=" + partitions.size() + ")"); } else { LOG.info("Can't find partitions for adding."); } query.clearPartitions(); } } catch (Throwable e) { query.eventHandler.handle(new QueryDiagnosticsUpdateEvent(query.id, ExceptionUtils.getStackTrace(e))); return QueryState.QUERY_ERROR; } return QueryState.QUERY_SUCCEEDED; }