| 174 | } |
| 175 | |
| 176 | public LogicalPlan parse(String query) throws ParserException { |
| 177 | LogicalPlan plan = null; |
| 178 | |
| 179 | ScriptState ss = ScriptState.get(); |
| 180 | CommonTokenStream tokenStream = tokenize(query, ss.getFileName()); |
| 181 | |
| 182 | Tree ast = parse( tokenStream ); |
| 183 | ast = expandMacro( ast ); |
| 184 | |
| 185 | try{ |
| 186 | ast = validateAst( ast ); |
| 187 | applyRegisters(ast); |
| 188 | |
| 189 | LogicalPlanGenerator planGenerator = |
| 190 | new LogicalPlanGenerator( new CommonTreeNodeStream( ast ), pigContext, scope, fileNameMap ); |
| 191 | planGenerator.query(); |
| 192 | |
| 193 | checkError( planGenerator ); |
| 194 | |
| 195 | plan = planGenerator.getLogicalPlan(); |
| 196 | operators = planGenerator.getOperators(); |
| 197 | lastRel = planGenerator.getLastRel(); |
| 198 | } catch(RecognitionException ex) { |
| 199 | throw new ParserException( ex ); |
| 200 | } catch(Exception ex) { |
| 201 | throw new ParserException( ex.getMessage(), ex ); |
| 202 | } |
| 203 | |
| 204 | return plan; |
| 205 | } |
| 206 | |
| 207 | public Map<String, Operator> getOperators() { |
| 208 | return operators; |