use of org.teiid.query.sql.util.SymbolMap in project teiid by teiid.
the class TestFrameUtil method testJoinGroups.
@Test
public void testJoinGroups() throws Exception {
PlanNode joinNode = getExamplePlan();
PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("e1");
e1.setGroupSymbol(getGroup(3));
projectNode.setProperty(Info.PROJECT_COLS, Arrays.asList(e1));
projectNode.addFirstChild(joinNode);
projectNode.addGroup(getGroup(3));
PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
sourceNode.addFirstChild(projectNode);
GroupSymbol four = getGroup(4);
sourceNode.addGroup(four);
// $NON-NLS-1$
ElementSymbol e2 = new ElementSymbol("e2");
e2.setGroupSymbol(four);
SymbolMap sm = SymbolMap.createSymbolMap(Arrays.asList(e2), Arrays.asList(e1));
sourceNode.setProperty(Info.SYMBOL_MAP, sm);
PlanNode projectNode1 = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
projectNode1.addFirstChild(sourceNode);
projectNode1.addGroup(four);
projectNode1.setProperty(Info.PROJECT_COLS, Arrays.asList(e2));
// removing source node 3 completely
SymbolMap replacement = SymbolMap.createSymbolMap(Arrays.asList(e1), Arrays.asList(new Constant(null)));
FrameUtil.convertFrame(NodeEditor.findNodePreOrder(joinNode, NodeConstants.Types.SOURCE), getGroup(3), null, replacement.asMap(), null);
// even though this is a cross join it should still retain its groups
assertEquals(2, joinNode.getGroups().size());
assertEquals(0, NodeEditor.findNodePreOrder(joinNode, NodeConstants.Types.SELECT).getGroups().size());
assertEquals(1, projectNode1.getGroups().size());
assertEquals(0, projectNode.getGroups().size());
}
Aggregations