use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestVirtualDepJoin method helpTestMultipleBatches.
private void helpTestMultipleBatches(boolean unique) throws Exception, TeiidComponentException, TeiidException, SQLException {
// Create query
// $NON-NLS-1$
String sql = "SELECT * from Master.Transactions where last = 'Davis' order by CustomerID, TransactionID";
List<List<Object>> expected = new LinkedList<List<Object>>();
// Create expected results
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }));
if (!unique) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }));
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(16000), new Long(207), new Integer(3), new BigDecimal("12.34") }));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(16000), new Long(299), new Integer(3), new BigDecimal("950.34") }));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(550), new Long(1004), new Integer(3), new BigDecimal("542.20") }));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(550), new Long(1005), new Integer(1), new BigDecimal("99.99") }));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(620), new Long(1006), new Integer(1), new BigDecimal("10000.00") }));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(620), new Long(1007), new Integer(2), new BigDecimal("0.75") }));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(630), new Long(1008), new Integer(2), new BigDecimal("62.00") }));
// Construct data manager with data
QueryMetadataInterface metadata = exampleVirtualDepJoin();
FakeDataManager dataManager = new FakeDataManager();
sampleDataVirtualDepJoin(dataManager, metadata);
overrideVirtualDepJoinData(dataManager, metadata, unique);
// Plan query
CommandContext context = TestProcessor.createCommandContext();
Command command = TestProcessor.helpParse(sql);
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
// $NON-NLS-1$
finder.addCapabilities("US", caps);
// $NON-NLS-1$
finder.addCapabilities("Europe", caps);
// $NON-NLS-1$
finder.addCapabilities("CustomerMaster", caps);
ProcessorPlan plan = TestProcessor.helpGetPlan(command, metadata, finder, context);
// Run query
BufferManager bufferMgr = createCustomBufferMgr(2);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
TupleBuffer id = collector.collectTuples();
TestProcessor.examineResults(expected.toArray(new List[expected.size()]), bufferMgr, id);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestVirtualDepJoin method testVirtualDepJoinOverAggregates2.
/**
* same as testVirtualDepJoinOverAggregate, but the makenotdep hint prevents the
* dependent join from happening
*/
@Test
public void testVirtualDepJoinOverAggregates2() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "select first, last, sum(amount) from Europe.CustAccts e makenotdep join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { "Miles", "Davis", new BigDecimal("1007.20") }) };
// Construct data manager with data
QueryMetadataInterface metadata = exampleVirtualDepJoin();
FakeDataManager dataManager = new FakeDataManager();
sampleDataVirtualDepJoin(dataManager, metadata);
// Plan query
CommandContext context = TestProcessor.createCommandContext();
Command command = TestProcessor.helpParse(sql);
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
// $NON-NLS-1$
finder.addCapabilities("Europe", caps);
// $NON-NLS-1$
finder.addCapabilities("CustomerMaster", caps);
ProcessorPlan plan = TestProcessor.helpGetPlan(command, metadata, finder, context);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
2, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
TestOptimizer.checkDependentJoinCount(plan, 0);
// Run query
TestProcessor.helpProcess(plan, context, dataManager, expected);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestVirtualDepJoin method testVirtualDepJoinPartialPushdown.
@Test
public void testVirtualDepJoinPartialPushdown() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "SELECT * from Master.Transactions where last = 'Davis'";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }) };
// Construct data manager with data
QueryMetadataInterface metadata = exampleVirtualDepJoin();
FakeDataManager dataManager = new FakeDataManager();
sampleDataVirtualDepJoin(dataManager, metadata);
// Plan query
CommandContext context = TestProcessor.createCommandContext();
Command command = TestProcessor.helpParse(sql);
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
BasicSourceCapabilities caps2 = TestOptimizer.getTypicalCapabilities();
caps2.setCapabilitySupport(Capability.CRITERIA_IN, false);
// $NON-NLS-1$
finder.addCapabilities("US", caps1);
// $NON-NLS-1$
finder.addCapabilities("Europe", caps2);
// $NON-NLS-1$
finder.addCapabilities("CustomerMaster", caps1);
ProcessorPlan plan = TestProcessor.helpGetPlan(command, metadata, finder, context);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
1, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
3, // Select
1, // Sort
0, // UnionAll
1 });
TestOptimizer.checkDependentJoinCount(plan, 1);
// Run query
TestProcessor.helpProcess(plan, context, dataManager, expected);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestVirtualDepJoin method testVirtualDepJoinNoValues.
@Test
public void testVirtualDepJoinNoValues() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first=-9999 group by c.id, first, last";
// Create expected results
List[] expected = new List[] {};
// Construct data manager with data
QueryMetadataInterface metadata = exampleVirtualDepJoin();
FakeDataManager dataManager = new FakeDataManager();
sampleDataVirtualDepJoin(dataManager, metadata);
// Plan query
CommandContext context = TestProcessor.createCommandContext();
Command command = TestProcessor.helpParse(sql);
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
// $NON-NLS-1$
finder.addCapabilities("Europe", caps);
// $NON-NLS-1$
finder.addCapabilities("CustomerMaster", caps);
ProcessorPlan plan = TestProcessor.helpGetPlan(command, metadata, finder, context);
TestOptimizer.checkDependentJoinCount(plan, 1);
// Run query
TestProcessor.helpProcess(plan, context, dataManager, expected);
// Second query *will not be run* as no values were passed and dependent side has always false criteria
// So, the list should contain only the first query
assertEquals(3, dataManager.getQueries().size());
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestVirtualDepJoin method testVirtualMakeDepHint.
@Test
public void testVirtualMakeDepHint() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "select distinct pm1.g1.e1 from (pm1.g1 inner join pm1.g2 on g1.e1 = g2.e1) makedep inner join pm2.g1 on pm2.g1.e1 = pm1.g1.e1 where pm2.g1.e3 = 1";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "a" }), // $NON-NLS-1$
Arrays.asList(new Object[] { "c" }) };
// Construct data manager with data
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
// Plan query
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
3, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
1, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
2, // Null
0, // PlanExecution
0, // Project
1, // Select
2, // Sort
0, // UnionAll
0 });
TestOptimizer.checkDependentJoinCount(plan, 1);
// Run query
TestProcessor.helpProcess(plan, new CommandContext(), dataManager, expected);
}
Aggregations