use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestProcessor method testCase5413.
@Test
public void testCase5413() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Plan query
// $NON-NLS-1$
String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 0) = e1";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
Command command = TestProcessor.helpParse(sql);
CommandContext context = createCommandContext();
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
// Run query
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "a" }) };
FakeDataManager dataManager = new FakeDataManager();
FakeDataStore.sampleData2(dataManager);
helpProcess(plan, context, dataManager, expected);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestProcessor method testDefect5004a.
/**
* Test to ensure that multiple empty batches are handled by the grouping node as well
*/
@Test
public void testDefect5004a() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx'";
// Create expected results
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(0) }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
CommandContext context = createCommandContext();
context.setProcessorBatchSize(2);
context.setMetadata(RealMetadataFactory.example1Cached());
// Plan query
ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
// Run query
helpProcess(plan, context, dataManager, expected);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestQueryProcessor method testCloseBeforeInitialization.
@Test
public void testCloseBeforeInitialization() throws TeiidComponentException {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
FakeDataManager dataManager = new FakeDataManager();
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "group", null, null, 1);
QueryProcessor processor = new QueryProcessor(null, context, bufferMgr, dataManager);
processor.closeProcessing();
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestRowBasedSecurity method testSelectFilterOuterJoin1.
@Test
public void testSelectFilterOuterJoin1() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table t (x string, y integer); create foreign table t1 (x string, y integer); create view v as select t.x, t1.y from t left outer join t1 on t.y = t1.y", "x", "y");
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, false);
CommandContext context = createCommandContext();
DQPWorkContext workContext = new DQPWorkContext();
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
DataPolicyMetadata policy = new DataPolicyMetadata();
pmd = new PermissionMetaData();
pmd.setResourceName("y.v");
pmd.setCondition("x = user()");
policy.addPermission(pmd);
policy.setName("some-role");
policies.put("some-role", policy);
workContext.setPolicies(policies);
context.setDQPWorkContext(workContext);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.y AS c_0, g_0.x AS c_1 FROM y.t AS g_0 ORDER BY c_0", new List<?>[] { Arrays.asList(1, "a"), Arrays.asList(2, "b") });
dataManager.addData("SELECT g_0.y AS c_0 FROM y.t1 AS g_0 ORDER BY c_0", new List<?>[] { Arrays.asList(1) });
ProcessorPlan plan = helpGetPlan(helpParse("select count(1) from v"), tm, new DefaultCapabilitiesFinder(caps), context);
List<?>[] expectedResults = new List<?>[] { Arrays.asList(0) };
helpProcess(plan, context, dataManager, expectedResults);
plan = helpGetPlan(helpParse("select count(1) from v where y is not null"), tm, new DefaultCapabilitiesFinder(caps), context);
dataManager.addData("SELECT g_0.y FROM y.t AS g_0 WHERE g_0.x = 'user'", new List<?>[] { Arrays.asList(1), Arrays.asList(2) });
dataManager.addData("SELECT g_0.y AS c_0 FROM y.t1 AS g_0 WHERE g_0.y IS NOT NULL ORDER BY c_0", Arrays.asList(1));
expectedResults = new List<?>[] { Arrays.asList(1) };
helpProcess(plan, context, dataManager, expectedResults);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestSQLXMLProcessing method executeStreaming.
private void executeStreaming(String sql, final List<?>[] expected, int batchSize) throws Throwable {
final CommandContext cc = createCommandContext();
if (batchSize != -1) {
cc.setBufferManager(BufferManagerFactory.getTestBufferManager(0, 1));
}
final ResultsFuture<Runnable> r = new ResultsFuture<Runnable>();
Executor ex = new Executor() {
@Override
public void execute(Runnable command) {
r.getResultsReceiver().receiveResults(command);
}
};
cc.setExecutor(ex);
final ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), cc);
final ResultsFuture<Void> result = new ResultsFuture<Void>();
Thread t = new Thread() {
@Override
public void run() {
try {
doProcess(plan, dataManager, expected, cc);
result.getResultsReceiver().receiveResults(null);
} catch (Throwable e) {
result.getResultsReceiver().exceptionOccurred(e);
}
}
};
t.start();
Runnable runnable = r.get();
runnable.run();
try {
result.get();
} catch (ExecutionException e) {
if (e.getCause() != null) {
throw e.getCause();
}
throw e;
}
}
Aggregations