private void addView(QueryMetadataInterface metadata, CommandContext context, GroupSymbol group, List<ElementSymbol> cols, PlanNode viewRoot) throws TeiidComponentException, QueryMetadataException, QueryPlannerException { GroupSymbol securityVeiw = new GroupSymbol("sec"); //$NON-NLS-1$ Set<String> groups = context.getGroups(); securityVeiw = RulePlaceAccess.recontextSymbol(securityVeiw, groups); List<ElementSymbol> newCols = RulePushAggregates.defineNewGroup(securityVeiw, cols, metadata); PlanNode newSourceNode = RuleDecomposeJoin.createSource(securityVeiw, viewRoot, newCols); Map<ElementSymbol, Expression> upperMapping = SymbolMap.createSymbolMap(cols, newCols).asMap(); FrameUtil.convertFrame(newSourceNode.getParent(), group, Collections.singleton(securityVeiw), upperMapping, metadata); }
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryMetadataException, TeiidComponentException, QueryPlannerException { Set<String> groups = context.getGroups(); boolean[] addtionalRules = new boolean[2]; for (PlanNode sourceNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) { addAccessNode(metadata, sourceNode, capFinder, addtionalRules); addAlias(sourceNode, context, groups, metadata); } if (addtionalRules[0]) { rules.addLast(RuleConstants.ACCESS_PATTERN_VALIDATION); } if (addtionalRules[1]) { rules.addLast(RuleConstants.VALIDATE_WHERE_ALL); } return plan; }
private static void prepareFrame(PlanNode frame) { // find the new root of the frame so that access patterns can be propagated PlanNode newRoot = FrameUtil.findJoinSourceNode(frame.getFirstChild()); if (newRoot != null) { Collection<AccessPattern> ap = (Collection)frame.getProperty(NodeConstants.Info.ACCESS_PATTERNS); if (ap != null) { Collection<AccessPattern> newAp = (Collection)newRoot.getProperty(NodeConstants.Info.ACCESS_PATTERNS); if (newAp == null) { newRoot.setProperty(NodeConstants.Info.ACCESS_PATTERNS, ap); } else { newAp.addAll(ap); } } RulePlaceAccess.copyProperties(frame, newRoot); } }
accessNode.addGroups(sourceNode.getGroups()); copyProperties(sourceNode, accessNode); SourceHint sourceHint = (SourceHint)sourceNode.removeProperty(Info.SOURCE_HINT); if (!isInsert && addAccessPatternsProperty(apNode, metadata)) { additionalRules[0] = true;
/** * 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$ }
accessNode.addGroups(sourceNode.getGroups()); copyProperties(sourceNode, accessNode); SourceHint sourceHint = (SourceHint)sourceNode.removeProperty(Info.SOURCE_HINT); if (!isInsert && addAccessPatternsProperty(apNode, metadata)) { additionalRules[0] = true;
RulePlaceAccess.addAccessPatternsProperty(accessNode1, metadata); RulePlaceAccess.addAccessPatternsProperty(accessNode2, metadata);
private void addView(QueryMetadataInterface metadata, CommandContext context, GroupSymbol group, List<ElementSymbol> cols, PlanNode viewRoot) throws TeiidComponentException, QueryMetadataException, QueryPlannerException { GroupSymbol securityVeiw = new GroupSymbol("sec"); //$NON-NLS-1$ Set<String> groups = context.getGroups(); securityVeiw = RulePlaceAccess.recontextSymbol(securityVeiw, groups); List<ElementSymbol> newCols = RulePushAggregates.defineNewGroup(securityVeiw, cols, metadata); PlanNode newSourceNode = RuleDecomposeJoin.createSource(securityVeiw, viewRoot, newCols); Map<ElementSymbol, Expression> upperMapping = SymbolMap.createSymbolMap(cols, newCols).asMap(); FrameUtil.convertFrame(newSourceNode.getParent(), group, Collections.singleton(securityVeiw), upperMapping, metadata); }
accessNode.addGroups(sourceNode.getGroups()); copyProperties(sourceNode, accessNode); SourceHint sourceHint = (SourceHint)sourceNode.removeProperty(Info.SOURCE_HINT); if (!isInsert && addAccessPatternsProperty(apNode, metadata)) { additionalRules[0] = true;
private static void prepareFrame(PlanNode frame) { // find the new root of the frame so that access patterns can be propagated PlanNode newRoot = FrameUtil.findJoinSourceNode(frame.getFirstChild()); if (newRoot != null) { Collection<AccessPattern> ap = (Collection)frame.getProperty(NodeConstants.Info.ACCESS_PATTERNS); if (ap != null) { Collection<AccessPattern> newAp = (Collection)newRoot.getProperty(NodeConstants.Info.ACCESS_PATTERNS); if (newAp == null) { newRoot.setProperty(NodeConstants.Info.ACCESS_PATTERNS, ap); } else { newAp.addAll(ap); } } RulePlaceAccess.copyProperties(frame, newRoot); } }
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryMetadataException, TeiidComponentException, QueryPlannerException { Set<String> groups = context.getGroups(); boolean[] addtionalRules = new boolean[2]; for (PlanNode sourceNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) { addAccessNode(metadata, sourceNode, capFinder, addtionalRules); addAlias(sourceNode, context, groups, metadata); } if (addtionalRules[0]) { rules.addLast(RuleConstants.ACCESS_PATTERN_VALIDATION); } if (addtionalRules[1]) { rules.addLast(RuleConstants.VALIDATE_WHERE_ALL); } return plan; }
private void addView(QueryMetadataInterface metadata, CommandContext context, GroupSymbol group, List<ElementSymbol> cols, List<? extends Expression> old, PlanNode viewRoot) throws TeiidComponentException, QueryMetadataException, QueryPlannerException { GroupSymbol securityVeiw = new GroupSymbol("sec"); //$NON-NLS-1$ Set<String> groups = context.getGroups(); securityVeiw = RulePlaceAccess.recontextSymbol(securityVeiw, groups); List<ElementSymbol> newCols = RulePushAggregates.defineNewGroup(securityVeiw, old, metadata); PlanNode newSourceNode = RuleDecomposeJoin.createSource(securityVeiw, viewRoot, newCols); Map<ElementSymbol, Expression> upperMapping = SymbolMap.createSymbolMap(cols, newCols).asMap(); FrameUtil.convertFrame(newSourceNode.getParent(), group, Collections.singleton(securityVeiw), upperMapping, metadata); }
private static void prepareFrame(PlanNode frame) { // find the new root of the frame so that access patterns can be propagated PlanNode newRoot = FrameUtil.findJoinSourceNode(frame.getFirstChild()); if (newRoot != null) { Collection<AccessPattern> ap = (Collection)frame.getProperty(NodeConstants.Info.ACCESS_PATTERNS); if (ap != null) { Collection<AccessPattern> newAp = (Collection)newRoot.getProperty(NodeConstants.Info.ACCESS_PATTERNS); if (newAp == null) { newRoot.setProperty(NodeConstants.Info.ACCESS_PATTERNS, ap); } else { newAp.addAll(ap); } } RulePlaceAccess.copyProperties(frame, newRoot); } }
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryMetadataException, TeiidComponentException, QueryPlannerException { Set<String> groups = context.getGroups(); boolean[] addtionalRules = new boolean[2]; for (PlanNode sourceNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) { addAccessNode(metadata, sourceNode, capFinder, addtionalRules); addAlias(sourceNode, context, groups, metadata); } if (addtionalRules[0]) { rules.addLast(RuleConstants.ACCESS_PATTERN_VALIDATION); } if (addtionalRules[1]) { rules.addLast(RuleConstants.VALIDATE_WHERE_ALL); } return plan; }
/** * Add the new union back in under a view */ static PlanNode rebuild(GroupSymbol group, PlanNode toReplace, PlanNode newUnion, QueryMetadataInterface metadata, CommandContext context, PlanNode... toMap) throws TeiidComponentException, QueryPlannerException, QueryMetadataException { Set<String> groups = context.getGroups(); group = RulePlaceAccess.recontextSymbol(group, groups); PlanNode projectNode = NodeEditor.findNodePreOrder(newUnion, NodeConstants.Types.PROJECT); List<? extends Expression> projectedSymbols = (List<? extends Expression>)projectNode.getProperty(Info.PROJECT_COLS); SymbolMap newSymbolMap = RulePushAggregates.createSymbolMap(group, projectedSymbols, newUnion, metadata); PlanNode view = RuleDecomposeJoin.createSource(group, newUnion, newSymbolMap); Map<Expression, ElementSymbol> inverseMap = newSymbolMap.inserseMapping(); if (toReplace != null) { toReplace.getParent().replaceChild(toReplace, view); } Set<GroupSymbol> newGroups = Collections.singleton(group); for (PlanNode node : toMap) { FrameUtil.convertFrame(view, node.getGroups().iterator().next(), newGroups, inverseMap, metadata); } return view; }
RulePlaceAccess.copyProperties(newChild.getFirstChild(), newChild); newChild.addLastChild(other); newChild.setProperty(Info.JOIN_CRITERIA, joinCriteria);
private void processWith(final QueryCommand command, List<WithQueryCommand> withList) throws QueryMetadataException, TeiidComponentException { for (int i = 0; i < withList.size(); i++) { WithQueryCommand with = withList.get(i); //check for a duplicate with clause, which can occur in a self-join scenario WithQueryCommand existing = this.withPlanningState.withList.get(with.getCommand()); if (existing != null) { final GroupSymbol old = with.getGroupSymbol(); replaceSymbol(command, old, existing.getGroupSymbol()); continue; } final GroupSymbol old = with.getGroupSymbol(); if (!context.getGroups().add(old.getName()) || old.getName().matches("(g|v)_\\d*")) { final GroupSymbol gs = RulePlaceAccess.recontextSymbol(old, context.getGroups()); LinkedHashMap<ElementSymbol, Expression> replacementSymbols = FrameUtil.buildSymbolMap(old, gs, metadata); gs.setDefinition(null); //update the with clause with the new group name / columns with.setGroupSymbol(gs); with.setColumns(new ArrayList(replacementSymbols.values())); //we use equality checks here because there may be a similarly named at lower scopes replaceSymbol(command, old, gs); } this.context.getAliasMapping().put(with.getGroupSymbol().getName(), old.getName()); this.withPlanningState.withList.put(with.getCommand(), with); } }
RulePlaceAccess.copyProperties(newChild.getFirstChild(), newChild); newChild.addLastChild(other); newChild.setProperty(Info.JOIN_CRITERIA, joinCriteria);
/** * Add the new union back in under a view */ static PlanNode rebuild(GroupSymbol group, PlanNode toReplace, PlanNode newUnion, QueryMetadataInterface metadata, CommandContext context, PlanNode... toMap) throws TeiidComponentException, QueryPlannerException, QueryMetadataException { Set<String> groups = context.getGroups(); group = RulePlaceAccess.recontextSymbol(group, groups); PlanNode projectNode = NodeEditor.findNodePreOrder(newUnion, NodeConstants.Types.PROJECT); List<? extends Expression> projectedSymbols = (List<? extends Expression>)projectNode.getProperty(Info.PROJECT_COLS); SymbolMap newSymbolMap = RulePushAggregates.createSymbolMap(group, projectedSymbols, newUnion, metadata); PlanNode view = RuleDecomposeJoin.createSource(group, newUnion, newSymbolMap); Map<Expression, ElementSymbol> inverseMap = newSymbolMap.inserseMapping(); if (toReplace != null) { toReplace.getParent().replaceChild(toReplace, view); } Set<GroupSymbol> newGroups = Collections.singleton(group); for (PlanNode node : toMap) { FrameUtil.convertFrame(view, node.getGroups().iterator().next(), newGroups, inverseMap, metadata); } return view; }
RulePlaceAccess.copyProperties(other, accessNode); RulePlaceAccess.copyProperties(joinNode, accessNode); combineSourceHints(accessNode, other);