}
}
static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) throws TeiidException {
if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
if (!(metadata instanceof TempMetadataAdapter)) {
metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
}
context.setMetadata(metadata);
try {
QueryResolver.resolveCommand(command, metadata);
ValidatorReport repo = Validator.validate(command, metadata);
Collection failures = new ArrayList();
repo.collectInvalidObjects(failures);
if (failures.size() > 0){
fail("Exception during validation (" + repo); //$NON-NLS-1$
}
command = QueryRewriter.rewrite(command, metadata, context);
ProcessorPlan process = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, context);
if(DEBUG) System.out.println("\n" + process); //$NON-NLS-1$
//per defect 10022, clone this plan before processing, just to make sure
//a cloned plan with correlated subquery references (or any cloned plan) can be processed
process = process.clone();
assertNotNull("Output elements of process plan are null", process.getOutputElements()); //$NON-NLS-1$
return process;
} finally {
if(DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
}