use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestTupleSourceCache method testNodeId.
@Test
public void testNodeId() throws Exception {
TupleSourceCache tsc = new TupleSourceCache();
HardcodedDataManager pdm = new HardcodedDataManager() {
@Override
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
assertEquals(1, parameterObject.nodeID);
return Mockito.mock(TupleSource.class);
}
};
CommandContext context = TestProcessor.createCommandContext();
BufferManagerImpl bufferMgr = BufferManagerFactory.createBufferManager();
Command command = new Insert();
RegisterRequestParameter parameterObject = new RegisterRequestParameter("z", 1, 1);
parameterObject.info = new RegisterRequestParameter.SharedAccessInfo();
tsc.getSharedTupleSource(context, command, "x", parameterObject, bufferMgr, pdm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestTupleSourceCache method testJoinProcessingWithNestedSubquery.
@Test
public void testJoinProcessingWithNestedSubquery() throws Exception {
HardcodedDataManager pdm = new HardcodedDataManager();
pdm.setBlockOnce(true);
String sql = "select e1 from (select e1, e2 from pm1.g1 where (select e3 from pm2.g1) = true) x inner join (select e2 from pm1.g2) y on x.e2 = y.e2 " + "union all " + "select e1 from (select e1, e2 from pm1.g1 where (select e3 from pm2.g1) = true) x inner join (select e2 from pm1.g2) y on x.e2 = y.e2";
pdm.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", Arrays.asList(1, "a"));
pdm.addData("SELECT pm1.g2.e2 FROM pm1.g2", Arrays.asList(1));
pdm.addData("SELECT pm2.g1.e3 FROM pm2.g1", Arrays.asList(true));
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
TestProcessor.helpProcess(plan, pdm, new List<?>[] { Arrays.asList("a"), Arrays.asList("a") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method testGroupByCountPushdownMultiSource.
@Test
public void testGroupByCountPushdownMultiSource() throws Exception {
String userSql = "SELECT s.e1, m.e1, COUNT(*) FROM pm1.g1 AS s INNER JOIN pm2.g2 AS m ON s.e2 = m.e2 GROUP BY s.e1, m.e1";
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e2", Arrays.asList(1, 2));
hdm.addData("SELECT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm2.g2 AS g_0 ORDER BY c_0", Arrays.asList(1, "other"));
BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
TransformationMetadata metadata = RealMetadataFactory.example1Cached();
final List<?>[] expected = new List<?>[] { Arrays.asList("a", "other", 2), Arrays.asList("b", "other", 2) };
VDBMetaData vdb = new VDBMetaData();
vdb.setName("exampleMultiBinding");
vdb.setVersion(1);
ModelMetaData model = new ModelMetaData();
model.setName("pm1");
model.setModelType(Model.Type.PHYSICAL);
model.setVisible(true);
model.setSupportsMultiSourceBindings(true);
model.addProperty(MultiSourceMetadataWrapper.MULTISOURCE_COLUMN_NAME, "e1");
vdb.addModel(model);
helpTestMultiSourcePlan(metadata, userSql, "pm1", 2, hdm, expected, vdb, null, new Options().implicitMultiSourceJoin(false), bsc);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method testAggParitioned.
@Test
public void testAggParitioned() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
// $NON-NLS-1$
final String userSql = "SELECT max(phys.a), source_name FROM MultiModel.Phys group by Phys.source_name";
// $NON-NLS-1$
final String multiModel = "MultiModel";
final int sources = 2;
final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList("y", "a"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList("y", "b") };
final HardcodedDataManager dataMgr = new HardcodedDataManager();
// $NON-NLS-1$
dataMgr.addData(// $NON-NLS-1$
"SELECT MAX(g_0.a) FROM MultiModel.Phys AS g_0", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList("y") });
ProcessorPlan plan = helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
3, // 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
1 });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method testUnsupportedPredicate.
@Test
public void testUnsupportedPredicate() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
// $NON-NLS-1$
final String userSql = "SELECT phys.a FROM MultiModel.Phys where Phys.source_name like 'a%'";
// $NON-NLS-1$
final String multiModel = "MultiModel";
final int sources = 2;
final List<?>[] expected = new List<?>[] { Arrays.asList("a") };
final HardcodedDataManager dataMgr = new HardcodedDataManager();
// $NON-NLS-1$
dataMgr.addData(// $NON-NLS-1$
"SELECT MultiModel.Phys.a FROM MultiModel.Phys", new List<?>[] { Arrays.asList("a") });
helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false), new BasicSourceCapabilities());
assertEquals(3, dataMgr.getCommandHistory().size());
}
Aggregations