use of org.teiid.query.metadata.TempMetadataAdapter in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method helpTestMultiSourcePlan.
public ProcessorPlan helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List<?>[] expectedResults, VDBMetaData vdb, List<?> params, Options options, SourceCapabilities bsc) throws Exception {
Map<String, String> multiSourceModels = MultiSourceMetadataWrapper.getMultiSourceModels(vdb);
for (String model : multiSourceModels.keySet()) {
char sourceID = 'a';
// by default every model has one binding associated, but for multi-source there were none assigned.
ModelMetaData m = vdb.getModel(model);
int x = m.getSourceNames().size();
for (int i = x; i < sourceCount; i++, sourceID++) {
// $NON-NLS-1$ //$NON-NLS-2$
m.addSourceMapping("" + sourceID, "translator", null);
}
}
QueryMetadataInterface wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
wrapper = new TempMetadataAdapter(wrapper, new TempMetadataStore());
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(wrapper, vdb);
AnalysisRecord analysis = new AnalysisRecord(DEBUG, DEBUG);
Command command = TestResolver.helpResolve(userSql, wrapper);
ValidatorReport report = Validator.validate(command, metadata);
if (report.hasItems()) {
fail(report.toString());
}
// Plan
command = QueryRewriter.rewrite(command, wrapper, null);
DefaultCapabilitiesFinder fakeFinder = new DefaultCapabilitiesFinder(bsc);
CapabilitiesFinder finder = new TempCapabilitiesFinder(fakeFinder);
IDGenerator idGenerator = new IDGenerator();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
CommandContext context = new CommandContext("test", "user", null, vdb.getName(), vdb.getVersion(), false);
context.setDQPWorkContext(workContext);
context.setOptions(options);
ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);
if (DEBUG) {
System.out.println(analysis.getDebugLog());
// $NON-NLS-1$
System.out.println("\nMultiSource Plan:");
System.out.println(plan);
}
if (params != null) {
TestProcessor.setParameterValues(params, command, context);
}
TestProcessor.helpProcess(plan, context, dataMgr, expectedResults);
return plan;
}
use of org.teiid.query.metadata.TempMetadataAdapter in project teiid by teiid.
the class TestStoredProcedurePlanning method testStoredQuery15.
/**
* Test planning stored queries. GeminiStoredQueryTestPlan - 6d
*/
@Ignore("stored procedure wrapper removal logic has been removed")
@Test
public void testStoredQuery15() {
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"EXEC pm1.sq10('1', 2)", // $NON-NLS-1$
new TempMetadataAdapter(RealMetadataFactory.example1Cached(), new TempMetadataStore()), // $NON-NLS-1$
new String[] { "SELECT e1 FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" });
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.TempMetadataAdapter in project teiid by teiid.
the class TestStoredProcedurePlanning method testStoredQuery10.
/**
* Test planning stored queries. GeminiStoredQueryTestPlan - 5b
*/
@Ignore("stored procedure wrapper removal logic has been removed")
@Test
public void testStoredQuery10() {
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"EXEC pm1.sq5('1')", // $NON-NLS-1$
new TempMetadataAdapter(RealMetadataFactory.example1Cached(), new TempMetadataStore()), // $NON-NLS-1$
new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" });
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.TempMetadataAdapter in project teiid by teiid.
the class TestStoredProcedurePlanning method testStoredQuery21.
// GeminiStoredQueryTestPlan - 4b
@Ignore("stored procedure wrapper removal logic has been removed")
@Test
public void testStoredQuery21() {
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"EXEC pm1.sq15('1', 2)", // $NON-NLS-1$
new TempMetadataAdapter(RealMetadataFactory.example1Cached(), new TempMetadataStore()), // $NON-NLS-1$
new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" });
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.TempMetadataAdapter in project teiid by teiid.
the class TestStoredProcedurePlanning method testStoredQuery5.
@Test
public void testStoredQuery5() {
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"EXEC pm1.sp1()", // $NON-NLS-1$
new TempMetadataAdapter(RealMetadataFactory.example1Cached(), new TempMetadataStore()), // $NON-NLS-1$
new String[] { "EXEC pm1.sp1()" });
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
Aggregations