Search in sources :

Example 81 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestAccessPatterns method testCase6425_4.

@Test
public void testCase6425_4() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e2 = '2'";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    TestOptimizer.helpPlan(sql, metadata, null, TestOptimizer.ComparisonMode.FAILED_PLANNING);
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 82 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestAccessPatterns method testMultiAccessPatternWithCriteria.

/*
     * Criteria was preventing rule choose dependent from creating the appropriate dependent join
     */
@Test
public void testMultiAccessPatternWithCriteria() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' ";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    AnalysisRecord record = new AnalysisRecord(true, true);
    TestOptimizer.helpPlanCommand(TestOptimizer.helpGetCommand(sql, metadata, null), metadata, TestOptimizer.getGenericFinder(false), record, new String[] { // $NON-NLS-1$
    "SELECT g_0.e2, g_0.e1 FROM pm5.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", // $NON-NLS-1$
    "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    assertTrue(record.getAnnotations().toString().contains("access pattern not satisfied by join"));
}
Also used : AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 83 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestAccessPatterns method testCase6425_2.

@Test
public void testCase6425_2() {
    // $NON-NLS-1$
    String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR (e1 = '2' AND e2 = 3)";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT e1 FROM pm4.g1 WHERE (e1 = '1') OR ((e1 = '2') AND (e2 = 3))" });
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 84 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestOptimizer method testSameConnector.

/**
 * Normally the following queries would plan as if they were federated, but setting the connector_id source property
 * allows them to be planned as if they were the same source.
 */
@Test
public void testSameConnector() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
    caps.setCapabilitySupport(Capability.QUERY_UNION, true);
    // $NON-NLS-1$
    caps.setSourceProperty(Capability.CONNECTOR_ID, "1");
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT2", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA A LEFT OUTER JOIN BQT2.MediumB B ON A.IntKey = B.IntKey", metadata, null, capFinder, new String[] { // $NON-NLS-1$
    "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA AS A LEFT OUTER JOIN BQT2.MediumB AS B ON A.IntKey = B.IntKey" }, true);
    checkNodeTypes(plan, FULL_PUSHDOWN);
    plan = helpPlan(// $NON-NLS-1$
    "SELECT A.IntKey FROM BQT1.SmallA A UNION select B.intkey from BQT2.MediumB B", metadata, null, capFinder, new String[] { // $NON-NLS-1$
    "SELECT A.IntKey FROM BQT1.SmallA AS A UNION SELECT B.intkey FROM BQT2.MediumB AS B" }, true);
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 85 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestOptimizer method testPushConvertClobToString.

@Test
public void testPushConvertClobToString() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
    // $NON-NLS-1$
    caps.setFunctionSupport("convert", true);
    // $NON-NLS-1$
    capFinder.addCapabilities("LOB", caps);
    // Add join capability to pm1
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT ClobValue from LOB.LobTbl WHERE convert(ClobValue, string) = ?", metadata, null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT LOB.LobTbl.ClobValue FROM LOB.LobTbl WHERE convert(LOB.LobTbl.ClobValue, string) = ?" }, SHOULD_SUCCEED);
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Aggregations

QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)507 Test (org.junit.Test)464 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)210 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)189 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)177 List (java.util.List)126 Command (org.teiid.query.sql.lang.Command)90 ArrayList (java.util.ArrayList)72 FakeDataManager (org.teiid.query.processor.FakeDataManager)48 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)43 BigInteger (java.math.BigInteger)41 CommandContext (org.teiid.query.util.CommandContext)37 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)29 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)16 MetadataStore (org.teiid.metadata.MetadataStore)12 Schema (org.teiid.metadata.Schema)11 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)11 TeiidException (org.teiid.core.TeiidException)10 TeiidProcessingException (org.teiid.core.TeiidProcessingException)10 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)10