private PlanNode buildNamedNode(String name) { PlanNode node = new PlanNode(); node.addGroup(new GroupSymbol(name)); return node; }
groupNode.addGroup(group); return map;
static PlanNode createSource(GroupSymbol group, PlanNode child, List<ElementSymbol> newProject) { PlanNode branchSource = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); branchSource.addGroup(group); PlanNode projectNode = NodeEditor.findNodePreOrder(child, NodeConstants.Types.PROJECT); branchSource.setProperty(Info.SYMBOL_MAP, SymbolMap.createSymbolMap(newProject, (List<? extends Expression>)projectNode.getProperty(Info.PROJECT_COLS))); child.addAsParent(branchSource); return branchSource; }
groupNode.addGroup(group); return map;
static PlanNode createSource(GroupSymbol group, PlanNode child, List<ElementSymbol> newProject) { PlanNode branchSource = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); branchSource.addGroup(group); PlanNode projectNode = NodeEditor.findNodePreOrder(child, NodeConstants.Types.PROJECT); branchSource.setProperty(Info.SYMBOL_MAP, SymbolMap.createSymbolMap(newProject, (List<? extends Expression>)projectNode.getProperty(Info.PROJECT_COLS))); child.addAsParent(branchSource); return branchSource; }
groupNode.addGroup(group); return map;
static PlanNode createSource(GroupSymbol group, PlanNode child, List<ElementSymbol> newProject) { PlanNode branchSource = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); branchSource.addGroup(group); PlanNode projectNode = NodeEditor.findNodePreOrder(child, NodeConstants.Types.PROJECT); branchSource.setProperty(Info.SYMBOL_MAP, SymbolMap.createSymbolMap(newProject, (List<? extends Expression>)projectNode.getProperty(Info.PROJECT_COLS))); child.addAsParent(branchSource); return branchSource; }
public PlanNode createAccessNode(Collection groupSymbols) throws Exception { PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN); PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_INNER); List crits = new ArrayList(); crits.add(new CompareCriteria(getElementSymbol(1,1), CompareCriteria.EQ, getElementSymbol(2,1))); joinNode.setProperty(NodeConstants.Info.JOIN_CRITERIA, crits); joinNode.addFirstChild(accessNode); accessNode.addFirstChild(sourceNode); Iterator i = groupSymbols.iterator(); while (i.hasNext()) { GroupSymbol gs = (GroupSymbol)i.next(); accessNode.addGroup(gs); sourceNode.addGroup(gs); } return accessNode; }
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)); nullNode.addGroup(getGroup(1)); joinNode.addFirstChild(nullNode); childCriteria.addGroup(getGroup(2)); joinNode.addLastChild(childCriteria); childJoinNode.addGroup(getGroup(2)); childJoinNode.addGroup(getGroup(3)); childCriteria.addFirstChild(childJoinNode); accessNode.addGroup(getGroup(2)); childJoinNode.addFirstChild(accessNode); sourceNode.addGroup(getGroup(3)); childJoinNode.addFirstChild(sourceNode);
@Test public void testValidJoin6() throws Exception { PlanNode accessNode1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); PlanNode accessNode2 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); accessNode1.addGroup(getPhysicalGroup(1)); accessNode2.addGroup(getPhysicalGroup(2)); PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN); joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_LEFT_OUTER); List crits = new ArrayList(); crits.add(new CompareCriteria(getElementSymbol(1,1), CompareCriteria.EQ, getElementSymbol(2,1))); joinNode.setProperty(NodeConstants.Info.JOIN_CRITERIA, crits); joinNode.addLastChild(accessNode1); joinNode.addLastChild(accessNode2); helpTestValidJoin(joinNode, accessNode2, true); }
@Test public void testValidJoin3() throws Exception { PlanNode accessNode1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); PlanNode accessNode2 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); accessNode1.addGroup(getPhysicalGroup(1)); accessNode2.addGroup(getPhysicalGroup(2)); PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN); joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_RIGHT_OUTER); List crits = new ArrayList(); crits.add(new CompareCriteria(getElementSymbol(1,1), CompareCriteria.EQ, getElementSymbol(2,1))); joinNode.setProperty(NodeConstants.Info.JOIN_CRITERIA, crits); joinNode.addLastChild(accessNode1); joinNode.addLastChild(accessNode2); helpTestValidJoin(joinNode, accessNode1, true); }
@Test public void testValidJoin2() throws Exception { PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); accessNode.addGroup(getPhysicalGroup(1)); PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN); joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_FULL_OUTER); joinNode.setProperty(NodeConstants.Info.JOIN_CRITERIA, Arrays.asList(QueryRewriter.FALSE_CRITERIA)); joinNode.addFirstChild(accessNode); helpTestValidJoin(joinNode, accessNode, false); }
PlanNode createStoredProcedurePlan(StoredProcedure storedProc) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException { // Create top project node - define output columns for stored query / procedure PlanNode projectNode = attachProject(null, storedProc.getProjectedSymbols()); // Define source of data for stored query / procedure PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc); addNestedProcedure(sourceNode, storedProc, storedProc.getProcedureID()); hints.hasRelationalProc |= storedProc.isProcedureRelational(); if (!hints.hasRowBasedSecurity && RowBasedSecurityHelper.applyRowSecurity(metadata, storedProc.getGroup(), context)) { hints.hasRowBasedSecurity = true; } // Set group on source node sourceNode.addGroup(storedProc.getGroup()); attachLast(projectNode, sourceNode); return projectNode; }
PlanNode createStoredProcedurePlan(StoredProcedure storedProc) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException { // Create top project node - define output columns for stored query / procedure PlanNode projectNode = attachProject(null, storedProc.getProjectedSymbols()); // Define source of data for stored query / procedure PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc); addNestedProcedure(sourceNode, storedProc, storedProc.getProcedureID()); hints.hasRelationalProc |= storedProc.isProcedureRelational(); if (!hints.hasRowBasedSecurity && RowBasedSecurityHelper.applyRowSecurity(metadata, storedProc.getGroup(), context)) { hints.hasRowBasedSecurity = true; } // Set group on source node sourceNode.addGroup(storedProc.getGroup()); attachLast(projectNode, sourceNode); return projectNode; }
PlanNode createStoredProcedurePlan(StoredProcedure storedProc) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException { // Create top project node - define output columns for stored query / procedure PlanNode projectNode = attachProject(null, storedProc.getProjectedSymbols()); // Define source of data for stored query / procedure PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE); sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc); addNestedProcedure(sourceNode, storedProc, storedProc.getProcedureID()); hints.hasRelationalProc |= storedProc.isProcedureRelational(); if (!hints.hasRowBasedSecurity && RowBasedSecurityHelper.applyRowSecurity(metadata, storedProc.getGroup(), context)) { hints.hasRowBasedSecurity = true; } // Set group on source node sourceNode.addGroup(storedProc.getGroup()); attachLast(projectNode, sourceNode); return projectNode; }
@Test public void testJoinGroups1() throws Exception { PlanNode joinNode = getExamplePlan(); PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT); ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$ 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"); //$NON-NLS-1$ 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)); //replace source 3 with groups 5, 6 SymbolMap replacement = SymbolMap.createSymbolMap(Arrays.asList(e1), Arrays.asList(new Constant(null))); FrameUtil.convertFrame(NodeEditor.findNodePreOrder(joinNode, NodeConstants.Types.SOURCE), getGroup(3), new HashSet<GroupSymbol>(Arrays.asList(getGroup(5), getGroup(6))), replacement.asMap(), null); assertEquals(4, joinNode.getGroups().size()); //even though this is a cross join it should still retain its groups assertEquals(0, NodeEditor.findNodePreOrder(joinNode, NodeConstants.Types.SELECT).getGroups().size()); assertEquals(1, projectNode1.getGroups().size()); assertEquals(0, projectNode.getGroups().size()); }
@Test public void testValidJoin1() throws Exception { PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); accessNode.addGroup(getPhysicalGroup(1)); PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN); joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_CROSS); joinNode.addFirstChild(accessNode); helpTestValidJoin(joinNode, accessNode, false); }
@Test public void testJoinGroups() throws Exception { PlanNode joinNode = getExamplePlan(); PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT); ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$ 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"); //$NON-NLS-1$ 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); assertEquals(2, joinNode.getGroups().size()); //even though this is a cross join it should still retain its groups assertEquals(0, NodeEditor.findNodePreOrder(joinNode, NodeConstants.Types.SELECT).getGroups().size()); assertEquals(1, projectNode1.getGroups().size()); assertEquals(0, projectNode.getGroups().size()); }
/** * Tests that any access patterns (a Collection of Collections of * Object element ids) for a physical group will be found and added * as a property of an ACCESS node. */ public void testAddAccessPatterns2() throws Exception { Query query = new Query(); From from = new From(); GroupSymbol group = new GroupSymbol("pm4.g2"); //$NON-NLS-1$ from.addGroup(group); query.setFrom(from); Select select = new Select(); select.addSymbol(new MultipleElementSymbol()); query.setSelect(select); group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$ PlanNode n1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); n1.setProperty(NodeConstants.Info.ATOMIC_REQUEST, query); n1.addGroup(group); RulePlaceAccess.addAccessPatternsProperty(n1, METADATA); Collection accessPatterns = (Collection)n1.getProperty(NodeConstants.Info.ACCESS_PATTERNS); assertNotNull(accessPatterns); assertTrue("Expected two access patterns, got " + accessPatterns.size(), accessPatterns.size() == 2); //$NON-NLS-1$ }
sourceNode.addGroup(target); Object id = getTrackableGroup(target, metadata); if (id != null) {