Search in sources :

Example 36 with TempMetadataAdapter

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;
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) CommandContext(org.teiid.query.util.CommandContext) TempCapabilitiesFinder(org.teiid.query.metadata.TempCapabilitiesFinder) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) ValidatorReport(org.teiid.query.validator.ValidatorReport) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) TempCapabilitiesFinder(org.teiid.query.metadata.TempCapabilitiesFinder) CapabilitiesFinder(org.teiid.query.optimizer.capabilities.CapabilitiesFinder) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) IDGenerator(org.teiid.core.id.IDGenerator) TempMetadataStore(org.teiid.query.metadata.TempMetadataStore)

Example 37 with TempMetadataAdapter

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);
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) TempMetadataStore(org.teiid.query.metadata.TempMetadataStore) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 38 with TempMetadataAdapter

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);
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) TempMetadataStore(org.teiid.query.metadata.TempMetadataStore) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 39 with TempMetadataAdapter

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);
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) TempMetadataStore(org.teiid.query.metadata.TempMetadataStore) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 40 with TempMetadataAdapter

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 });
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) TempMetadataStore(org.teiid.query.metadata.TempMetadataStore) Test(org.junit.Test)

Aggregations

TempMetadataAdapter (org.teiid.query.metadata.TempMetadataAdapter)53 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)45 Test (org.junit.Test)32 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)32 Ignore (org.junit.Ignore)21 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)9 CommandContext (org.teiid.query.util.CommandContext)6 List (java.util.List)4 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)4 TempMetadataID (org.teiid.query.metadata.TempMetadataID)4 Command (org.teiid.query.sql.lang.Command)4 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)4 TeiidComponentException (org.teiid.core.TeiidComponentException)3 TeiidProcessingException (org.teiid.core.TeiidProcessingException)3 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)3 TempCapabilitiesFinder (org.teiid.query.metadata.TempCapabilitiesFinder)3 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)3 GroupContext (org.teiid.query.sql.lang.GroupContext)3 TempTableStore (org.teiid.query.tempdata.TempTableStore)3 ArrayList (java.util.ArrayList)2