Search in sources :

Example 1 with LimitNode

use of org.teiid.query.processor.relational.LimitNode in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testMultiReplacementWithLimit1.

@Test
public void testMultiReplacementWithLimit1() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT a, b FROM MultiModel.Phys limit 1, 1";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a AS c_0, g_0.b AS c_1 FROM MultiModel.Phys AS g_0 LIMIT 2", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y", "z"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z") });
    RelationalPlan plan = (RelationalPlan) helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
    assertTrue(plan.getRootNode() instanceof LimitNode);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) LimitNode(org.teiid.query.processor.relational.LimitNode) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 2 with LimitNode

use of org.teiid.query.processor.relational.LimitNode in project teiid by teiid.

the class TestSortOptimization method testProjectionRaisingWithLimit1.

@Test
public void testProjectionRaisingWithLimit1() {
    // Create query
    // $NON-NLS-1$
    String sql = "select (select e1 from pm2.g1 where e2 = x.e2) as z from pm1.g1 as x order by z limit 2";
    RelationalPlan plan = (RelationalPlan) helpPlan(sql, RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] { "SELECT pm1.g1.e2 FROM pm1.g1" }, // $NON-NLS-1$
    TestOptimizer.SHOULD_SUCCEED);
    assertTrue(plan.getRootNode() instanceof LimitNode);
}
Also used : LimitNode(org.teiid.query.processor.relational.LimitNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 3 with LimitNode

use of org.teiid.query.processor.relational.LimitNode in project teiid by teiid.

the class CriteriaCapabilityValidatorVisitor method getAccessNode.

public static AccessNode getAccessNode(ProcessorPlan plan) {
    if (!(plan instanceof RelationalPlan)) {
        return null;
    }
    RelationalPlan rplan = (RelationalPlan) plan;
    // Check that the plan is just an access node
    RelationalNode accessNode = rplan.getRootNode();
    if (accessNode instanceof LimitNode) {
        LimitNode ln = (LimitNode) accessNode;
        if (!ln.isImplicit()) {
            return null;
        }
        accessNode = ln.getChildren()[0];
    }
    if (!(accessNode instanceof AccessNode)) {
        return null;
    }
    return (AccessNode) accessNode;
}
Also used : RelationalNode(org.teiid.query.processor.relational.RelationalNode) LimitNode(org.teiid.query.processor.relational.LimitNode) AccessNode(org.teiid.query.processor.relational.AccessNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan)

Aggregations

LimitNode (org.teiid.query.processor.relational.LimitNode)3 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)3 Test (org.junit.Test)2 List (java.util.List)1 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)1 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)1 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)1 AccessNode (org.teiid.query.processor.relational.AccessNode)1 RelationalNode (org.teiid.query.processor.relational.RelationalNode)1