Search in sources :

Example 6 with PlanNode

use of org.teiid.query.optimizer.relational.plantree.PlanNode in project teiid by teiid.

the class TestFrameUtil method testFindJoinSourceNode.

@Test
public void testFindJoinSourceNode() {
    PlanNode root = getExamplePlan();
    PlanNode joinSource = FrameUtil.findJoinSourceNode(root);
    assertSame(root, joinSource);
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) Test(org.junit.Test)

Example 7 with PlanNode

use of org.teiid.query.optimizer.relational.plantree.PlanNode in project teiid by teiid.

the class TestJoinRegion method testFindJoinRegions.

public void testFindJoinRegions() {
    List regions = new ArrayList();
    PlanNode joinRoot = TestFrameUtil.getExamplePlan();
    PlanNode joinRoot1 = TestFrameUtil.getExamplePlan();
    PlanNode outerJoin = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
    outerJoin.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_LEFT_OUTER);
    outerJoin.addFirstChild(joinRoot);
    outerJoin.addFirstChild(joinRoot1);
    PlanNode source = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
    source.addFirstChild(outerJoin);
    RulePlanJoins.findJoinRegions(source, null, regions);
    assertEquals(3, regions.size());
    JoinRegion region = (JoinRegion) regions.get(0);
    // ensure that the first region is the trivial region of the outer join
    assertEquals(1, region.getJoinSourceNodes().size());
}
Also used : JoinRegion(org.teiid.query.optimizer.relational.rules.JoinRegion) PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 8 with PlanNode

use of org.teiid.query.optimizer.relational.plantree.PlanNode in project teiid by teiid.

the class TestRuleAccessPatternValidation method helpPlan.

/**
 * Parses and resolves the command, creates a canonical relational plan,
 * and runs some of the optimizer rules, ending with the
 * RuleChooseAccessPattern.
 * @param command String command to parse, resolve and use for planning
 * @param rules empty RuleStack
 * @param groups Collection to add parsed and resolved GroupSymbols to
 * @return the root PlanNode of the query plan
 */
private PlanNode helpPlan(String command) throws Exception {
    Command query = QueryParser.getQueryParser().parseCommand(command);
    QueryResolver.resolveCommand(query, METADATA);
    // Generate canonical plan
    RelationalPlanner p = new RelationalPlanner();
    p.initialize(query, null, METADATA, FINDER, null, new CommandContext());
    PlanNode planNode = p.generatePlan(query);
    RelationalPlanner planner = new RelationalPlanner();
    final RuleStack rules = planner.buildRules();
    PlanNode testPlan = helpExecuteRules(rules, planNode, METADATA, DEBUG);
    return testPlan;
}
Also used : RelationalPlanner(org.teiid.query.optimizer.relational.RelationalPlanner) PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) RuleStack(org.teiid.query.optimizer.relational.RuleStack)

Example 9 with PlanNode

use of org.teiid.query.optimizer.relational.plantree.PlanNode in project teiid by teiid.

the class TestRuleAssignOutputElements method testFindNoAllUnion1.

@Test
public void testFindNoAllUnion1() {
    PlanNode projNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
    PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    projNode.addLastChild(accessNode);
    helpTestIsUnionNoAll(projNode, false);
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) Test(org.junit.Test)

Example 10 with PlanNode

use of org.teiid.query.optimizer.relational.plantree.PlanNode in project teiid by teiid.

the class TestRuleAssignOutputElements method testFindNoAllUnion3.

@Test
public void testFindNoAllUnion3() {
    PlanNode unionNode = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
    unionNode.setProperty(NodeConstants.Info.SET_OPERATION, Operation.UNION);
    unionNode.setProperty(NodeConstants.Info.USE_ALL, Boolean.FALSE);
    PlanNode projNode1 = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
    PlanNode accessNode1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    PlanNode projNode2 = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
    PlanNode accessNode2 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    unionNode.addLastChild(projNode1);
    projNode1.addLastChild(accessNode1);
    unionNode.addLastChild(projNode2);
    projNode2.addLastChild(accessNode2);
    helpTestIsUnionNoAll(unionNode, true);
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) Test(org.junit.Test)

Aggregations

PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)204 Expression (org.teiid.query.sql.symbol.Expression)50 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)50 ArrayList (java.util.ArrayList)47 List (java.util.List)43 SymbolMap (org.teiid.query.sql.util.SymbolMap)42 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)36 Criteria (org.teiid.query.sql.lang.Criteria)35 LinkedList (java.util.LinkedList)24 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)24 Test (org.junit.Test)22 HashSet (java.util.HashSet)17 JoinType (org.teiid.query.sql.lang.JoinType)17 LinkedHashSet (java.util.LinkedHashSet)16 CompoundCriteria (org.teiid.query.sql.lang.CompoundCriteria)12 DependentSetCriteria (org.teiid.query.sql.lang.DependentSetCriteria)12 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)11 LanguageObject (org.teiid.query.sql.LanguageObject)11 OrderBy (org.teiid.query.sql.lang.OrderBy)10 IsNullCriteria (org.teiid.query.sql.lang.IsNullCriteria)9