Search in sources :

Example 1 with PlanNode

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

the class TestFrameUtil method testFindSourceNode2.

@Test
public void testFindSourceNode2() {
    PlanNode root = getExamplePlan();
    Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
    groups.add(getGroup(3));
    PlanNode originatingNode = FrameUtil.findOriginatingNode(root, groups);
    assertEquals(NodeConstants.Types.SOURCE, originatingNode.getType());
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with PlanNode

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

the class TestFrameUtil method testNonExistentSource.

@Test
public void testNonExistentSource() {
    PlanNode root = getExamplePlan();
    Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
    groups.add(getGroup(4));
    PlanNode originatingNode = FrameUtil.findOriginatingNode(root, groups);
    assertNull(originatingNode);
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with PlanNode

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

the class TestFrameUtil method getExamplePlan.

/**
 * <pre>
 * Join(groups=[3, 2, 1])
 *   Null(groups=[1])
 *   Select(groups=[2])
 *     Join(groups=[3, 2])
 *       Source(groups=[3])
 *       Access(groups=[2])
 * </pre>
 */
public static PlanNode getExamplePlan() {
    PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
    joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_CROSS);
    joinNode.addGroup(getGroup(1));
    joinNode.addGroup(getGroup(2));
    joinNode.addGroup(getGroup(3));
    PlanNode nullNode = NodeFactory.getNewNode(NodeConstants.Types.NULL);
    nullNode.addGroup(getGroup(1));
    joinNode.addFirstChild(nullNode);
    PlanNode childCriteria = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
    childCriteria.setProperty(Info.SELECT_CRITERIA, new IsNullCriteria(new Constant(1)));
    childCriteria.addGroup(getGroup(2));
    joinNode.addLastChild(childCriteria);
    PlanNode childJoinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
    childJoinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_CROSS);
    childJoinNode.addGroup(getGroup(2));
    childJoinNode.addGroup(getGroup(3));
    childCriteria.addFirstChild(childJoinNode);
    PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    accessNode.addGroup(getGroup(2));
    childJoinNode.addFirstChild(accessNode);
    PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
    sourceNode.addGroup(getGroup(3));
    childJoinNode.addFirstChild(sourceNode);
    return joinNode;
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) Constant(org.teiid.query.sql.symbol.Constant) IsNullCriteria(org.teiid.query.sql.lang.IsNullCriteria)

Example 4 with PlanNode

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

the class TestFrameUtil method testFindJoinSourceNode1.

@Test
public void testFindJoinSourceNode1() {
    PlanNode root = getExamplePlan();
    PlanNode joinSource = FrameUtil.findJoinSourceNode(root.getLastChild());
    assertEquals(NodeConstants.Types.JOIN, joinSource.getType());
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) Test(org.junit.Test)

Example 5 with PlanNode

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

the class TestFrameUtil method testFindSourceNode.

@Test
public void testFindSourceNode() {
    PlanNode root = getExamplePlan();
    Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
    groups.add(getGroup(1));
    PlanNode originatingNode = FrameUtil.findOriginatingNode(root, groups);
    assertEquals(NodeConstants.Types.NULL, originatingNode.getType());
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) HashSet(java.util.HashSet) 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