use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestPartialFilters method testFilterPlanning1.
@Test
public void testFilterPlanning1() throws Exception {
String ddl = "create foreign table People_Groups (user_dn string options (nameinsource 'dn'), group_dn string options (nameinsource 'memberOf', \"teiid_rel:partial_filter\" true)) options (nameinsource 'ou=people,dc=metamatrix,dc=com')";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.PARTIAL_FILTERS, true);
ProcessorPlan plan = TestOptimizer.helpPlan("select * from people_groups where group_dn > 'abc' and group_dn like 'a_'", RealMetadataFactory.fromDDL(ddl, "x", "y"), new String[] { "SELECT g_0.user_dn, g_0.group_dn FROM y.People_Groups AS g_0 WHERE (g_0.group_dn > 'abc') AND (g_0.group_dn LIKE 'a_')" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
0, // Select
1, // Sort
0, // UnionAll
0 });
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.user_dn, g_0.group_dn FROM y.People_Groups AS g_0 WHERE (g_0.group_dn > 'abc') AND (g_0.group_dn LIKE 'a_')", Arrays.asList("a", "aa"), Arrays.asList("a", "ac"), Arrays.asList("a", "e"));
TestProcessor.helpProcess(plan, dataManager, new List<?>[] { Arrays.asList("a", "ac") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestPartialFilters method testFilterPlanning.
@Test
public void testFilterPlanning() throws Exception {
String ddl = "create foreign table People_Groups (user_dn string options (nameinsource 'dn'), group_dn string options (nameinsource 'memberOf', \"teiid_rel:partial_filter\" true)) options (nameinsource 'ou=people,dc=metamatrix,dc=com')";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.PARTIAL_FILTERS, true);
ProcessorPlan plan = TestOptimizer.helpPlan("select * from people_groups where group_dn = 'a'", RealMetadataFactory.fromDDL(ddl, "x", "y"), new String[] { "SELECT g_0.user_dn, g_0.group_dn FROM y.People_Groups AS g_0 WHERE g_0.group_dn = 'a'" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
0, // Select
1, // Sort
0, // UnionAll
0 });
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.user_dn, g_0.group_dn FROM y.People_Groups AS g_0 WHERE g_0.group_dn = 'a'", Arrays.asList("b", "a"), Arrays.asList("b", "c"));
TestProcessor.helpProcess(plan, dataManager, new List<?>[] { Arrays.asList("b", "a") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestPartialFilters method testFilterPlanning2.
@Test
public void testFilterPlanning2() throws Exception {
String ddl = "create foreign table People_Groups (user_dn string options (nameinsource 'dn'), group_dn string options (nameinsource 'memberOf', \"teiid_rel:partial_filter\" true)) options (nameinsource 'ou=people,dc=metamatrix,dc=com')";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.PARTIAL_FILTERS, true);
ProcessorPlan plan = TestOptimizer.helpPlan("select group_dn from people_groups where group_dn > 'abc' or user_dn < 'def'", RealMetadataFactory.fromDDL(ddl, "x", "y"), new String[] { "SELECT g_0.group_dn, g_0.user_dn FROM y.People_Groups AS g_0 WHERE (g_0.group_dn > 'abc') OR (g_0.user_dn < 'def')" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.group_dn, g_0.user_dn FROM y.People_Groups AS g_0 WHERE (g_0.group_dn > 'abc') OR (g_0.user_dn < 'def')", Arrays.asList("a", "b"), Arrays.asList("d", "e"), Arrays.asList("a", "e"));
TestProcessor.helpProcess(plan, dataManager, new List<?>[] { Arrays.asList("a"), Arrays.asList("d") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestSortOptimization method testOffsetWithOrderBy.
@Test
public void testOffsetWithOrderBy() throws Exception {
String sql = "select e1 from pm1.g1 order by e1 offset 2 rows";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.e1 FROM pm1.g1 AS g_0", Arrays.asList("a"), Arrays.asList("b"), Arrays.asList("c"));
List<?>[] expectedResults = new List[] { Arrays.asList("c") };
TestProcessor.helpProcess(plan, dataManager, expectedResults);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestSortOptimization method testDistinctPushdownWithGrouping.
@Test
public void testDistinctPushdownWithGrouping() throws Exception {
String sql = "select distinct e1, e2, 1, 2 from (select e1, e2 from pm1.g1 group by e1, e2) v";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, false);
caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps), new String[] { "SELECT DISTINCT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT DISTINCT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0", Arrays.asList("a", 1), Arrays.asList("b", 2));
List<?>[] expectedResults = new List[] { Arrays.asList("a", 1, 1, 2), Arrays.asList("b", 2, 1, 2) };
TestProcessor.helpProcess(plan, dataManager, expectedResults);
}
Aggregations