Search in sources :

Example 1 with DefaultCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.

the class TestPreparedStatement method testLimit.

@Test
public void testLimit() throws Exception {
    // Create query
    // $NON-NLS-1$
    String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?";
    // $NON-NLS-1$
    List<?> values = Arrays.asList("0");
    // $NON-NLS-1$
    SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0);
    helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, RealMetadataFactory.example1VDB());
    helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, RealMetadataFactory.example1VDB());
    // make sure the plan wasn't reused
    assertEquals(1, planCache.getCacheHitCount());
}
Also used : DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 2 with DefaultCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.

the class TestPreparedStatement method testInherentlyUpdatableViewCompensation.

@Test
public void testInherentlyUpdatableViewCompensation() throws Exception {
    // $NON-NLS-1$
    String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN /*+ no_unnest */ (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)";
    List<?>[] expected = new List<?>[] { Arrays.asList("a") };
    // $NON-NLS-1$
    List<?> values = Arrays.asList("a");
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
    dataManager.addData("SELECT g_0.e1 FROM g1 AS g_0 WHERE g_0.e2 IN (SELECT g_1.e2 FROM g2 AS g_1 WHERE g_1.e1 = 'a')", new List<?>[] { Arrays.asList("a") });
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
    caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
    helpTestProcessing(preparedSql, values, expected, dataManager, new DefaultCapabilitiesFinder(caps), metadata, null, false, false, false, RealMetadataFactory.example1VDB());
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ArrayList(java.util.ArrayList) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 3 with DefaultCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.

the class TestPreparedStatement method testWithSubqueryPushdown.

@Test
public void testWithSubqueryPushdown() throws Exception {
    // $NON-NLS-1$
    String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN /*+ no_unnest */ (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)";
    List<?>[] expected = new List<?>[] { Arrays.asList("a") };
    // $NON-NLS-1$
    List<?> values = Arrays.asList("a");
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
    dataManager.addData("SELECT g_0.e1 FROM g1 AS g_0 WHERE g_0.e2 IN (SELECT g_1.e2 FROM g2 AS g_1 WHERE g_1.e1 = 'a')", new List<?>[] { Arrays.asList("a") });
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
    caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
    helpTestProcessing(preparedSql, values, expected, dataManager, new DefaultCapabilitiesFinder(caps), metadata, null, false, false, false, RealMetadataFactory.example1VDB());
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ArrayList(java.util.ArrayList) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 4 with DefaultCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.

the class TestOptimizer method testCase4017.

/*
     * Select literals created by runtime evaluation should not be pushed down.
     */
@Test
public void testCase4017() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT env('soap_host') AS HOST, intkey from bqt2.smalla";
    helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(), new String[] { "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 5 with DefaultCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.

the class TestOptimizer method testManyJoinsOverThreshold.

@Test
public void testManyJoinsOverThreshold() throws Exception {
    long begin = System.currentTimeMillis();
    helpPlan(// $NON-NLS-1$
    "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3, pm1.g4, pm1.g5, pm1.g6, pm1.g7, pm1.g8, pm1.g1 AS x, pm1.g2 AS y WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1 AND pm1.g3.e1 = pm1.g4.e1 AND pm1.g4.e1 = pm1.g5.e1 AND pm1.g5.e1=pm1.g6.e1 AND pm1.g6.e1=pm1.g7.e1 AND pm1.g7.e1=pm1.g8.e1", example1(), new String[] { // $NON-NLS-1$
    "SELECT pm1.g1.e1 FROM pm1.g1", // $NON-NLS-1$
    "SELECT pm1.g2.e1 FROM pm1.g2", // $NON-NLS-1$
    "SELECT pm1.g3.e1 FROM pm1.g3", // $NON-NLS-1$
    "SELECT pm1.g4.e1 FROM pm1.g4", // $NON-NLS-1$
    "SELECT pm1.g5.e1 FROM pm1.g5", // $NON-NLS-1$
    "SELECT pm1.g6.e1 FROM pm1.g6", // $NON-NLS-1$
    "SELECT pm1.g7.e1 FROM pm1.g7", // $NON-NLS-1$
    "SELECT pm1.g8.e1 FROM pm1.g8", // $NON-NLS-1$
    "SELECT x.e1 FROM pm1.g1 AS x", "SELECT y.e1 FROM pm1.g2 AS y" }, new DefaultCapabilitiesFinder(), // $NON-NLS-1$
    ComparisonMode.CORRECTED_COMMAND_STRING);
    long elapsed = System.currentTimeMillis() - begin;
    // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Did not plan many join query in reasonable time frame: " + elapsed + " ms", elapsed < 4000);
}
Also used : 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