planner.initialize(command, idGenerator, metadata, capFinder, analysisRecord, context); planner.executeRules(stack, plan);
/** * Parses and resolves the command, creates a canonical relational plan, * and runs some of the optimizer rules, ending with the * RuleChooseAccessPattern. * @param command String command to parse, resolve and use for planning * @param rules empty RuleStack * @param groups Collection to add parsed and resolved GroupSymbols to * @return the root PlanNode of the query plan */ private PlanNode helpPlan(String command) throws Exception { Command query = QueryParser.getQueryParser().parseCommand(command); QueryResolver.resolveCommand(query, METADATA); //Generate canonical plan RelationalPlanner p = new RelationalPlanner(); p.initialize(query, null, METADATA, FINDER, null, new CommandContext()); PlanNode planNode = p.generatePlan(query); RelationalPlanner planner = new RelationalPlanner(); final RuleStack rules = planner.buildRules(); PlanNode testPlan = helpExecuteRules(rules, planNode, METADATA, DEBUG); return testPlan; }
planner.initialize(command, idGenerator, metadata, capFinder, analysisRecord, context); planner.executeRules(stack, plan);
planner.initialize(command, idGenerator, metadata, capFinder, analysisRecord, context); planner.executeRules(stack, plan);
@Test public void testPushAcrossFrameWithAccessNode() throws Exception { QueryMetadataInterface metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), new TempMetadataStore()); Command command = TestOptimizer.helpGetCommand("select * from (select * from pm1.g1 union select * from pm1.g2) x where e1 = 1", metadata); //$NON-NLS-1$ Command subCommand = TestOptimizer.helpGetCommand("select * from pm1.g1 union select * from pm1.g2", metadata); //$NON-NLS-1$ RelationalPlanner p = new RelationalPlanner(); CommandContext cc = new CommandContext(); p.initialize(command, null, metadata, null, null, cc); PlanNode root = p.generatePlan(command); PlanNode child = p.generatePlan(subCommand); PlanNode sourceNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.SOURCE); sourceNode.addFirstChild(child); sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<Expression>)child.getFirstChild().getProperty(Info.PROJECT_COLS), metadata)); //add a dummy access node PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS); accessNode.addGroups(child.getFirstChild().getGroups()); child.getFirstChild().addAsParent(accessNode); new RulePushSelectCriteria().execute(root, metadata, new DefaultCapabilitiesFinder(), new RuleStack(), AnalysisRecord.createNonRecordingRecord(), cc); // the select node should still be above the access node accessNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.ACCESS); assertEquals(NodeConstants.Types.SELECT, accessNode.getParent().getType()); assertNull(NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.SELECT)); }
try { RelationalPlanner planner = new RelationalPlanner(); planner.initialize(command, idGenerator, metadata, capFinder, analysisRecord, context); result = planner.optimize(command); } catch (QueryResolverException e) {
try { RelationalPlanner planner = new RelationalPlanner(); planner.initialize(command, idGenerator, metadata, capFinder, analysisRecord, context); result = planner.optimize(command); } catch (QueryResolverException e) {
} else { RelationalPlanner planner = new RelationalPlanner(); planner.initialize(command, idGenerator, metadata, capFinder, analysisRecord, context); result = planner.optimize(command);