Search in sources :

Example 21 with SessionMetadata

use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.

the class TestFunctionLibrary method testInvokeUser.

@Test
public void testInvokeUser() throws Exception {
    CommandContext c = new CommandContext();
    // $NON-NLS-1$
    c.setUserName("foodude");
    c.setSession(new SessionMetadata());
    c.getSession().setSecurityDomain("x");
    // $NON-NLS-1$ //$NON-NLS-2$
    helpInvokeMethod("user", new Class<?>[] {}, new Object[] {}, c, "foodude@x");
}
Also used : CommandContext(org.teiid.query.util.CommandContext) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) Test(org.junit.Test)

Example 22 with SessionMetadata

use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.

the class TestWithClauseProcessing method testRecursiveWithProjectionMinimization.

@Test
public void testRecursiveWithProjectionMinimization() throws Exception {
    String sql = "WITH table3 (column5,column6,column7) AS (\n" + "SELECT column1, column2, column3 FROM table1 where column1 = 'joe'\n" + "UNION ALL \n" + "SELECT column1, column2, column3 FROM table1 inner join table3 on table3.column6=table1.column1  \n" + ") \n" + "SELECT column3, column4 FROM table2 WHERE column3 IN (SELECT column5 FROM table3)";
    String ddl = "CREATE FOREIGN TABLE table1 (\n" + "column1 string(4000),\n" + "column2 string(4000),\n" + "column3 string(4000)\n" + ") OPTIONS(NAMEINSOURCE 'table1', UPDATABLE 'TRUE');\n" + "\n" + "CREATE FOREIGN TABLE table2 (\n" + "column3 string(4000),\n" + "column4 string(4000)\n" + ") OPTIONS(NAMEINSOURCE 'table2', UPDATABLE 'TRUE');";
    TransformationMetadata metadata = RealMetadataFactory.fromDDL(ddl, "x", "y");
    CommandContext cc = createCommandContext();
    cc.setSession(new SessionMetadata());
    ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities()), cc);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("SELECT g_0.column1, g_0.column2 FROM y.table1 AS g_0 WHERE g_0.column1 = 'joe'", Arrays.asList("joe", "bob"));
    dataManager.addData("SELECT g_0.column1, g_0.column2 FROM y.table1 AS g_0 WHERE g_0.column1 = 'bob'");
    dataManager.addData("SELECT g_0.column3 AS c_0, g_0.column4 AS c_1 FROM y.table2 AS g_0 WHERE g_0.column3 = 'joe' ORDER BY c_0", Arrays.asList("joe", "employee"));
    helpProcess(plan, cc, dataManager, new List[] { Arrays.asList("joe", "employee") });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CommandContext(org.teiid.query.util.CommandContext) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 23 with SessionMetadata

use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.

the class TestWithClauseProcessing method testMaxRecursive.

@Test(expected = TeiidProcessingException.class)
public void testMaxRecursive() throws Exception {
    // $NON-NLS-1$
    String sql = "WITH t(n) AS ( VALUES (1) UNION ALL SELECT n+1 FROM t WHERE n < 64 ) SELECT sum(n) FROM t;";
    List<?>[] expected = new List[] { Arrays.asList(2080l) };
    FakeDataManager dataManager = new FakeDataManager();
    ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
    CommandContext cc = createCommandContext();
    cc.setSession(new SessionMetadata());
    cc.setSessionVariable(TempTableStore.TEIID_MAX_RECURSION, 10);
    helpProcess(plan, cc, dataManager, expected);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) List(java.util.List) Test(org.junit.Test)

Example 24 with SessionMetadata

use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.

the class TestWithClauseProcessing method testRecursive.

@Test
public void testRecursive() throws Exception {
    // $NON-NLS-1$
    String sql = "WITH t(n) AS ( VALUES (1) UNION ALL SELECT n+1 FROM t WHERE n < 64 ) SELECT sum(n) FROM t;";
    List<?>[] expected = new List[] { Arrays.asList(2080l) };
    FakeDataManager dataManager = new FakeDataManager();
    dataManager.setBlockOnce();
    sampleData1(dataManager);
    ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
    CommandContext cc = createCommandContext();
    cc.setSession(new SessionMetadata());
    helpProcess(plan, cc, dataManager, expected);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) List(java.util.List) Test(org.junit.Test)

Example 25 with SessionMetadata

use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.

the class RealMetadataFactory method buildWorkContext.

public static DQPWorkContext buildWorkContext(QueryMetadataInterface metadata, VDBMetaData vdb) {
    DQPWorkContext workContext = new DQPWorkContext();
    SessionMetadata session = new SessionMetadata();
    workContext.setSession(session);
    session.setVDBName(vdb.getName());
    session.setVDBVersion(vdb.getVersion());
    session.setSessionId(String.valueOf(1));
    // $NON-NLS-1$
    session.setUserName("foo");
    session.setVdb(vdb);
    workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
    if (metadata instanceof TransformationMetadata) {
        workContext.getVDB().addAttchment(TransformationMetadata.class, (TransformationMetadata) metadata);
    }
    DQPWorkContext.setWorkContext(workContext);
    return workContext;
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata)

Aggregations

SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)35 Test (org.junit.Test)14 CommandContext (org.teiid.query.util.CommandContext)9 Properties (java.util.Properties)6 InvalidSessionException (org.teiid.client.security.InvalidSessionException)6 DQPWorkContext (org.teiid.dqp.internal.process.DQPWorkContext)5 SessionServiceException (org.teiid.dqp.service.SessionServiceException)5 List (java.util.List)4 LoginException (javax.security.auth.login.LoginException)4 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)4 LogonException (org.teiid.client.security.LogonException)4 SessionToken (org.teiid.client.security.SessionToken)4 Credentials (org.teiid.security.Credentials)4 ArrayList (java.util.ArrayList)3 Subject (javax.security.auth.Subject)3 TeiidComponentException (org.teiid.core.TeiidComponentException)3 SQLException (java.sql.SQLException)2 LogonResult (org.teiid.client.security.LogonResult)2 CompositeVDB (org.teiid.deployers.CompositeVDB)2 VDBLifeCycleListener (org.teiid.deployers.VDBLifeCycleListener)2