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");
}
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") });
}
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);
}
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);
}
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;
}
Aggregations