Search in sources :

Example 6 with DQPWorkContext

use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.

the class TempTableDataManager method createWorkContext.

private DQPWorkContext createWorkContext(final CommandContext context, VDBMetaData vdb) {
    // $NON-NLS-1$
    SessionMetadata session = createTemporarySession(context.getUserName(), "asynch-mat-view-load", vdb);
    session.setSubject(context.getSubject());
    session.setSecurityDomain(context.getSession().getSecurityDomain());
    session.setSecurityContext(context.getSession().getSecurityContext());
    DQPWorkContext workContext = new DQPWorkContext();
    workContext.setAdmin(true);
    DQPWorkContext current = context.getDQPWorkContext();
    workContext.setSession(session);
    workContext.setPolicies(current.getAllowedDataPolicies());
    workContext.setSecurityHelper(current.getSecurityHelper());
    return workContext;
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata)

Example 7 with DQPWorkContext

use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.

the class TempTableDataManager method loadViaRefresh.

private void loadViaRefresh(final CommandContext context, final String tableName, VDBMetaData vdb, MatTableInfo info) throws TeiidProcessingException, TeiidComponentException {
    info.setAsynchLoad();
    DQPWorkContext workContext = createWorkContext(context, vdb);
    final String viewName = tableName.substring(RelationalPlanner.MAT_PREFIX.length());
    workContext.runInContext(new Runnable() {

        @Override
        public void run() {
            executor.execute(REFRESH_SQL, Arrays.asList(viewName, Boolean.FALSE));
        }
    });
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext)

Example 8 with DQPWorkContext

use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.

the class TestConnectorWorkItem method createNewAtomicRequestMessage.

static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
    RequestMessage rm = new RequestMessage();
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(EXAMPLE_BQT, RealMetadataFactory.exampleBQTVDB());
    workContext.getSession().setSessionId(String.valueOf(1));
    // $NON-NLS-1$
    workContext.getSession().setUserName("foo");
    AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
    // $NON-NLS-1$
    request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT));
    request.setRequestID(new RequestID(requestid));
    // $NON-NLS-1$
    request.setConnectorName("testing");
    request.setFetchSize(5);
    request.setCommandContext(new CommandContext());
    return request;
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) RequestID(org.teiid.dqp.message.RequestID) CommandContext(org.teiid.query.util.CommandContext) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage)

Example 9 with DQPWorkContext

use of org.teiid.dqp.internal.process.DQPWorkContext 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 10 with DQPWorkContext

use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.

the class TestColumnMasking method createContext.

private static CommandContext createContext() {
    CommandContext context = createCommandContext();
    DQPWorkContext workContext = new DQPWorkContext();
    HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
    DataPolicyMetadata policy = new DataPolicyMetadata();
    PermissionMetaData pmd = new PermissionMetaData();
    pmd.setResourceName("pm1.sp1.e1");
    pmd.setMask("case when e2 > 1 then null else e1 end");
    PermissionMetaData pmd1 = new PermissionMetaData();
    pmd1.setResourceName("pm1.g1.e2");
    pmd1.setMask("case when e1 = 'a' then null else e2 end");
    policy.addPermission(pmd, pmd1);
    policy.setName("some-role");
    policies.put("some-role", policy);
    workContext.setPolicies(policies);
    context.setDQPWorkContext(workContext);
    return context;
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) CommandContext(org.teiid.query.util.CommandContext) HashMap(java.util.HashMap) DataPolicyMetadata(org.teiid.adminapi.impl.DataPolicyMetadata) DataPolicy(org.teiid.adminapi.DataPolicy) PermissionMetaData(org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData)

Aggregations

DQPWorkContext (org.teiid.dqp.internal.process.DQPWorkContext)18 CommandContext (org.teiid.query.util.CommandContext)10 Test (org.junit.Test)8 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)5 List (java.util.List)4 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)4 HashMap (java.util.HashMap)3 Properties (java.util.Properties)3 DataPolicy (org.teiid.adminapi.DataPolicy)3 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)3 PermissionMetaData (org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData)3 LogonResult (org.teiid.client.security.LogonResult)3 Subject (javax.security.auth.Subject)2 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)2 VDBRepository (org.teiid.deployers.VDBRepository)2 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Future (java.util.concurrent.Future)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1