use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestProcessor method testUpsert.
@Test
public void testUpsert() throws Exception {
// $NON-NLS-1$
String sql = "upsert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)";
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1) }) };
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table g1 (e1 string, e2 integer, primary key (e1)) options (updatable true)", "x", "pm1");
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT 1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'MyString'", new List[] { Arrays.asList(1) });
dataManager.addData("UPDATE pm1.g1 SET e2 = 1 WHERE pm1.g1.e1 = 'MyString'", new List[] { Arrays.asList(1) });
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = helpGetPlan(sql, metadata, new DefaultCapabilitiesFinder(bsc));
helpProcess(plan, dataManager, expected);
dataManager.clearData();
// plan again with upsert pushdown
dataManager.addData("UPSERT INTO pm1.g1 (e1, e2) VALUES ('MyString', 1)", Arrays.asList(1));
bsc.setCapabilitySupport(Capability.UPSERT, true);
plan = helpGetPlan(sql, metadata, new DefaultCapabilitiesFinder(bsc));
helpProcess(plan, dataManager, expected);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestProcessor method testNestedRightJoinWithLateral.
@Test
public void testNestedRightJoinWithLateral() throws Exception {
String ddl = "create view v as select 1 a, 2 b;";
TransformationMetadata metadata = RealMetadataFactory.fromDDL(ddl, "x", "views");
String sql = "select * from (select 1 e1) g1, ((select 1 e1) g2 right outer join lateral(select g1.e1) x on g2.e1 = x.e1)";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata, new DefaultCapabilitiesFinder(caps));
HardcodedDataManager dataManager = new HardcodedDataManager();
TestProcessor.helpProcess(plan, dataManager, new List<?>[] { Arrays.asList(1, 1, 1) });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestProcessor method testCase6193_1.
@Test
public void testCase6193_1() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "select a.INTKEY, b.intkey from bqt1.smalla a LEFT OUTER JOIN bqt2.SMALLA b on a.intkey=b.intkey and a.intkey=5 where a.intkey <10 ";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
capFinder.addCapabilities("BQT2", caps);
// Create expected results
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(0), null }), Arrays.asList(new Object[] { new Integer(1), null }), Arrays.asList(new Object[] { new Integer(2), null }), Arrays.asList(new Object[] { new Integer(3), null }), Arrays.asList(new Object[] { new Integer(4), null }), Arrays.asList(new Object[] { new Integer(5), new Integer(5) }), Arrays.asList(new Object[] { new Integer(6), null }), Arrays.asList(new Object[] { new Integer(7), null }), Arrays.asList(new Object[] { new Integer(8), null }), Arrays.asList(new Object[] { new Integer(9), null }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleDataBQT2(dataManager);
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT b.IntKey FROM bqt2.SMALLA AS b", "SELECT a.IntKey FROM bqt1.smalla AS a" }, new DefaultCapabilitiesFinder(), // $NON-NLS-1$ //$NON-NLS-2$
ComparisonMode.CORRECTED_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
1, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
2, // Sort
0, // UnionAll
0 });
// Run query
helpProcess(plan, dataManager, expected);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestProcessor method testLimitZero1.
@Test
public void testLimitZero1() {
// $NON-NLS-1$
String sql = "select distinct vm1.g1.e1, y.e1 from vm1.g1 left outer join (select 1 x, e1 from vm1.g2 limit 0) y on vm1.g1.e1 = y.e1 where vm1.g1.e1 = 'a'";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder());
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
1, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
1, // Sort
0, // UnionAll
0 });
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "a", null }) };
FakeDataManager manager = new FakeDataManager();
sampleData1(manager);
helpProcess(plan, manager, expected);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestTextTable method testTextTableFixedWin.
@Test
public void testTextTableFixedWin() throws Exception {
// $NON-NLS-1$
String sql = "select max(compkey), max(cdm_id), max(currency), max(\"start\"), max(maturity), max(amount), count(*) from texttable(? COLUMNS compkey string width 76, CDM_ID string width 14, CURRENCY string width 9, \"START\" string width 31, MATURITY string width 31, AMOUNT double width 21, RECORDSOURCE string width 13, SUMMIT_ID string width 15, RATE double width 20, SPREAD double width 20, DESK string width 14) x";
List<?>[] expected = new List<?>[] { Arrays.asList("000369USD05/20/200405/20/2007", "000369", "USD", "12/18/2000", "12/19/2005", 6.7209685146E8, 52) };
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), Arrays.asList(clobFromFile("text/cdm_dos_win.txt")));
}
Aggregations