Source:
public ListenableFuture<Query> getResourceLog(final long queryId, final TupleWriter writer) throws DbException { final QueryStatusEncoding queryStatus; try { queryStatus = catalog.getQuery(queryId); } catch (CatalogException e) { throw new DbException(e); } Preconditions.checkArgument(queryStatus != null, "query %s not found", queryId); Set<Integer> actualWorkers = queryStatus.plan.getWorkers(); final Schema schema = MyriaConstants.RESOURCE_SCHEMA; String resourceQueryString = Joiner.on(' ').join( "SELECT * from " + MyriaConstants.RESOURCE_RELATION.toString(getDBMS()) + "WHERE queryId =", queryId); DbQueryScan scan = new DbQueryScan(resourceQueryString, schema); ImmutableList.Builder<Expression> emitExpressions = ImmutableList.builder(); for (int column = 0; column < schema.numColumns(); column++) { VariableExpression copy = new VariableExpression(column); emitExpressions.add(new Expression(schema.getColumnName(column), copy)); } emitExpressions.add(new Expression("workerId", new WorkerIdExpression())); Apply addWorkerId = new Apply(scan, emitExpressions.build()); final ExchangePairID operatorId = ExchangePairID.newID(); CollectProducer producer = new CollectProducer(addWorkerId, operatorId, MyriaConstants.MASTER_ID); SubQueryPlan workerPlan = new SubQueryPlan(producer); Map<Integer, SubQueryPlan> workerPlans = new HashMap<>(actualWorkers.size()); for (Integer worker : actualWorkers) { workerPlans.put(worker, workerPlan); } final CollectConsumer consumer = new CollectConsumer(addWorkerId.getSchema(), operatorId, ImmutableSet.copyOf(actualWorkers)); DataOutput output = new DataOutput(consumer, writer); final SubQueryPlan masterPlan = new SubQueryPlan(output); String planString = Joiner.on("").join("download resource log for (query=", queryId, ")"); try { return submitQuery(planString, planString, planString, masterPlan, workerPlans, null); } catch (CatalogException e) { throw new DbException(e); } }

Target:
public ListenableFuture<Query> getResourceLog(final long queryId, final TupleWriter writer) throws DbException { final QueryStatusEncoding queryStatus; try { queryStatus = catalog.getQuery(queryId); } catch (CatalogException e) { throw new DbException(e); } Preconditions.checkArgument(queryStatus != null, "query %s not found", queryId); Set<Integer> actualWorkers = queryStatus.plan.getWorkers(); final Schema schema = MyriaConstants.RESOURCE_SCHEMA; String resourceQueryString = Joiner.on(' ').join("SELECT * from", MyriaConstants.RESOURCE_RELATION.toString(getDBMS()), "WHERE \"queryId\" =", queryId); DbQueryScan scan = new DbQueryScan(resourceQueryString, schema); ImmutableList.Builder<Expression> emitExpressions = ImmutableList.builder(); for (int column = 0; column < schema.numColumns(); column++) { VariableExpression copy = new VariableExpression(column); emitExpressions.add(new Expression(schema.getColumnName(column), copy)); } emitExpressions.add(new Expression("workerId", new WorkerIdExpression())); Apply addWorkerId = new Apply(scan, emitExpressions.build()); final ExchangePairID operatorId = ExchangePairID.newID(); CollectProducer producer = new CollectProducer(addWorkerId, operatorId, MyriaConstants.MASTER_ID); SubQueryPlan workerPlan = new SubQueryPlan(producer); Map<Integer, SubQueryPlan> workerPlans = new HashMap<>(actualWorkers.size()); for (Integer worker : actualWorkers) { workerPlans.put(worker, workerPlan); } final CollectConsumer consumer = new CollectConsumer(addWorkerId.getSchema(), operatorId, ImmutableSet.copyOf(actualWorkers)); DataOutput output = new DataOutput(consumer, writer); final SubQueryPlan masterPlan = new SubQueryPlan(output); String planString = Joiner.on("").join("download resource log for (query=", queryId, ")"); try { return queryManager.submitQuery(planString, planString, planString, masterPlan, workerPlans, PROFILING_MODE.NONE); } catch (CatalogException e) { throw new DbException(e); } }