Search in sources :

Example 81 with DefaultCapabilitiesFinder

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);
}
Also used : BigInteger(java.math.BigInteger) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 82 with DefaultCapabilitiesFinder

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) });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 83 with DefaultCapabilitiesFinder

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);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BigInteger(java.math.BigInteger) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 84 with DefaultCapabilitiesFinder

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);
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 85 with DefaultCapabilitiesFinder

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")));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Aggregations

DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)361 Test (org.junit.Test)344 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)277 List (java.util.List)121 CommandContext (org.teiid.query.util.CommandContext)95 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)89 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)87 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)42 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)41 Command (org.teiid.query.sql.lang.Command)23 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)17 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)15 ArrayList (java.util.ArrayList)13 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)13 PermissionMetaData (org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData)13 Table (org.teiid.metadata.Table)12 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)7 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)7 TeiidComponentException (org.teiid.core.TeiidComponentException)6 TeiidProcessingException (org.teiid.core.TeiidProcessingException)6