use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestPreparedPlanCache method helpPutPreparedPlans.
// ====Help methods====//
private void helpPutPreparedPlans(SessionAwareCache<PreparedPlan> cache, DQPWorkContext session, int start, int count) {
for (int i = 0; i < count; i++) {
Command dummy;
try {
dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + (start + i));
} catch (QueryParserException e) {
throw new RuntimeException(e);
}
CacheID id = new CacheID(session, pi, dummy.toString());
PreparedPlan pPlan = new PreparedPlan();
cache.put(id, Determinism.SESSION_DETERMINISTIC, pPlan, null);
pPlan.setCommand(dummy);
pPlan.setPlan(new RelationalPlan(new ProjectNode(i)), new CommandContext());
AnalysisRecord analysisRecord = new AnalysisRecord(true, false);
pPlan.setAnalysisRecord(analysisRecord);
ArrayList<Reference> refs = new ArrayList<Reference>();
refs.add(new Reference(1));
pPlan.setReferences(refs);
}
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestOptimizer method getPlan.
public static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, boolean shouldSucceed, CommandContext cc) {
ProcessorPlan plan = null;
if (analysisRecord == null) {
analysisRecord = new AnalysisRecord(false, DEBUG);
}
Exception exception = null;
try {
// do planning
plan = QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, cc);
} catch (QueryPlannerException e) {
exception = e;
} catch (TeiidComponentException e) {
exception = e;
} catch (Throwable e) {
throw new TeiidRuntimeException(e);
} finally {
if (DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
if (!shouldSucceed) {
// $NON-NLS-1$
assertNotNull("Expected exception but did not get one.", exception);
return null;
}
if (plan == null) {
throw new TeiidRuntimeException(exception);
}
// $NON-NLS-1$
assertNotNull("Output elements are null", plan.getOutputElements());
// $NON-NLS-1$
if (DEBUG)
System.out.println("\n" + plan);
return plan;
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestBatchedUpdatePlanner method helpPlanCommand.
private BatchedUpdatePlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// plan
ProcessorPlan plan = null;
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
if (shouldSucceed) {
try {
// do planning
plan = QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, null);
} finally {
if (DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
return (BatchedUpdatePlan) plan;
}
Exception exception = null;
try {
// do planning
QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, null);
} catch (QueryPlannerException e) {
exception = e;
} catch (TeiidComponentException e) {
exception = e;
} finally {
if (DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
// $NON-NLS-1$
assertNotNull("Expected exception but did not get one.", exception);
return null;
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestAccessPatterns method testMultiAccessPatternWithCriteria.
/*
* Criteria was preventing rule choose dependent from creating the appropriate dependent join
*/
@Test
public void testMultiAccessPatternWithCriteria() throws Exception {
// $NON-NLS-1$
String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' ";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
AnalysisRecord record = new AnalysisRecord(true, true);
TestOptimizer.helpPlanCommand(TestOptimizer.helpGetCommand(sql, metadata, null), metadata, TestOptimizer.getGenericFinder(false), record, new String[] { // $NON-NLS-1$
"SELECT g_0.e2, g_0.e1 FROM pm5.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", // $NON-NLS-1$
"SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
assertTrue(record.getAnnotations().toString().contains("access pattern not satisfied by join"));
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestProcessor method helpGetPlan.
public static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) throws TeiidException {
// $NON-NLS-1$
if (DEBUG)
System.out.println("\n####################################\n" + command);
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) {
// $NON-NLS-1$
throw new QueryValidatorException("Exception during validation:" + repo);
}
command = QueryRewriter.rewrite(command, metadata, context);
ProcessorPlan process = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, context);
// $NON-NLS-1$
if (DEBUG)
System.out.println("\n" + process);
// 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();
// $NON-NLS-1$
assertNotNull("Output elements of process plan are null", process.getOutputElements());
return process;
} finally {
if (DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
}
Aggregations