@Test public void testJoinGroups() throws Exception { PlanNode joinNode = getExamplePlan(); PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT); 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); 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)); 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); 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()); }
public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) throws QueryPlannerException { PlanNode current = startNode; if (oldGroup != null && newGroups != null && newGroups.size() == 1 && startNode.getType() == NodeConstants.Types.SOURCE) { Map<ElementSymbol, List<Set<Constant>>> partitionInfo = (Map<ElementSymbol, List<Set<Constant>>>)startNode.getProperty(Info.PARTITION_INFO); if (partitionInfo != null) { startNode.setProperty(Info.PARTITION_INFO, RelationalPlanner.remapPartitionInfo(newGroups.iterator().next(), partitionInfo)); } } PlanNode endNode = NodeEditor.findParent(startNode.getType()==NodeConstants.Types.SOURCE?startNode.getParent():startNode, NodeConstants.Types.SOURCE); boolean rewrite = false; if (newGroups != null && newGroups.size() == 1) { for (Expression expression : (Collection<Expression>)symbolMap.values()) { if (!(expression instanceof ElementSymbol)) { rewrite = true; break; } } } else { rewrite = true; } while(current != endNode) { convertNode(current, oldGroup, newGroups, symbolMap, metadata, rewrite); PlanNode parent = current.getParent(); if (parent != null && parent.getType() == NodeConstants.Types.SET_OP && parent.getFirstChild() != current) { return; } current = parent; } if(endNode == null) { return; } correctSymbolMap(symbolMap, endNode); }
FrameUtil { public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) throws QueryPlannerException { PlanNode current = startNode; if (oldGroup != null && newGroups != null && newGroups.size() == 1 && startNode.getType() == NodeConstants.Types.SOURCE) { Map<ElementSymbol, List<Set<Constant>>> partitionInfo = (Map<ElementSymbol, List<Set<Constant>>>)startNode.getProperty(Info.PARTITION_INFO); if (partitionInfo != null) { startNode.setProperty(Info.PARTITION_INFO, RelationalPlanner.remapPartitionInfo(newGroups.iterator().next(), partitionInfo)); } } PlanNode endNode = NodeEditor.findParent(startNode.getType()==NodeConstants.Types.SOURCE?startNode.getParent():startNode, NodeConstants.Types.SOURCE); boolean rewrite = false; if (newGroups != null && newGroups.size() == 1) { for (Expression expression : (Collection<Expression>)symbolMap.values()) { if (!(expression instanceof ElementSymbol)) { rewrite = true; break; } } } else { rewrite = true; } while(current != endNode) { convertNode(current, oldGroup, newGroups, symbolMap, metadata, rewrite); PlanNode parent = current.getParent(); if (parent != null && parent.getType() == NodeConstants.Types.SET_OP && parent.getFirstChild() != current) { return; } current = parent; } if(endNode == null) { return; } correctSymbolMap(symbolMap, endNode); } }
FrameUtil { public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) throws QueryPlannerException { PlanNode current = startNode; if (oldGroup != null && newGroups != null && newGroups.size() == 1 && startNode.getType() == NodeConstants.Types.SOURCE) { Map<ElementSymbol, List<Set<Constant>>> partitionInfo = (Map<ElementSymbol, List<Set<Constant>>>)startNode.getProperty(Info.PARTITION_INFO); if (partitionInfo != null) { startNode.setProperty(Info.PARTITION_INFO, RelationalPlanner.remapPartitionInfo(newGroups.iterator().next(), partitionInfo)); } } PlanNode endNode = NodeEditor.findParent(startNode.getType()==NodeConstants.Types.SOURCE?startNode.getParent():startNode, NodeConstants.Types.SOURCE); boolean rewrite = false; if (newGroups != null && newGroups.size() == 1) { for (Expression expression : (Collection<Expression>)symbolMap.values()) { if (!(expression instanceof ElementSymbol)) { rewrite = true; break; } } } else { rewrite = true; } while(current != endNode) { convertNode(current, oldGroup, newGroups, symbolMap, metadata, rewrite); PlanNode parent = current.getParent(); if (parent != null && parent.getType() == NodeConstants.Types.SET_OP && parent.getFirstChild() != current) { return; } current = parent; } if(endNode == null) { return; } correctSymbolMap(symbolMap, endNode); }  }
FrameUtil { public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) throws QueryPlannerException { PlanNode current = startNode; if (oldGroup != null && newGroups != null && newGroups.size() == 1 && startNode.getType() == NodeConstants.Types.SOURCE) { Map<ElementSymbol, List<Set<Constant>>> partitionInfo = (Map<ElementSymbol, List<Set<Constant>>>)startNode.getProperty(Info.PARTITION_INFO); if (partitionInfo != null) { startNode.setProperty(Info.PARTITION_INFO, RelationalPlanner.remapPartitionInfo(newGroups.iterator().next(), partitionInfo)); } } PlanNode endNode = NodeEditor.findParent(startNode.getType()==NodeConstants.Types.SOURCE?startNode.getParent():startNode, NodeConstants.Types.SOURCE); boolean rewrite = false; if (newGroups != null && newGroups.size() == 1) { for (Expression expression : (Collection<Expression>)symbolMap.values()) { if (!(expression instanceof ElementSymbol)) { rewrite = true; break; } } } else { rewrite = true; } while(current != endNode) { convertNode(current, oldGroup, newGroups, symbolMap, metadata, rewrite); PlanNode parent = current.getParent(); if (parent != null && parent.getType() == NodeConstants.Types.SET_OP && parent.getFirstChild() != current) { return; } current = parent; } if(endNode == null) { return; } correctSymbolMap(symbolMap, endNode); }  static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata); static LinkedHashMap<ElementSymbol, Expression> buildSymbolMap(GroupSymbol oldGroup, GroupSymbol newGroup, QueryMetadataInterface metadata); static PlanNode findJoinSourceNode(PlanNode root); static ProcessorPlan getNestedPlan(PlanNode accessNode); static boolean isOrderedOrStrictLimit(PlanNode node); }
FrameUtil { public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) throws QueryPlannerException { PlanNode current = startNode; if (oldGroup != null && newGroups != null && newGroups.size() == 1 && startNode.getType() == NodeConstants.Types.SOURCE) { Map<ElementSymbol, List<Set<Constant>>> partitionInfo = (Map<ElementSymbol, List<Set<Constant>>>)startNode.getProperty(Info.PARTITION_INFO); if (partitionInfo != null) { startNode.setProperty(Info.PARTITION_INFO, RelationalPlanner.remapPartitionInfo(newGroups.iterator().next(), partitionInfo)); } } PlanNode endNode = NodeEditor.findParent(startNode.getType()==NodeConstants.Types.SOURCE?startNode.getParent():startNode, NodeConstants.Types.SOURCE); boolean rewrite = false; if (newGroups != null && newGroups.size() == 1) { for (Expression expression : (Collection<Expression>)symbolMap.values()) { if (!(expression instanceof ElementSymbol)) { rewrite = true; break; } } } else { rewrite = true; } while(current != endNode) { convertNode(current, oldGroup, newGroups, symbolMap, metadata, rewrite); PlanNode parent = current.getParent(); if (parent != null && parent.getType() == NodeConstants.Types.SET_OP && parent.getFirstChild() != current) { return; } current = parent; } if(endNode == null) { return; } correctSymbolMap(symbolMap, endNode); }  static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata); static LinkedHashMap<ElementSymbol, Expression> buildSymbolMap(GroupSymbol oldGroup, GroupSymbol newGroup, QueryMetadataInterface metadata); static PlanNode findJoinSourceNode(PlanNode root); static ProcessorPlan getNestedPlan(PlanNode accessNode); static boolean isOrderedOrStrictLimit(PlanNode node);  }