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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations