Author: olga Date: Wed Jul 23 12:35:55 2008 New Revision: 679166 URL: http://svn.apache.org/viewvc?rev=679166&view=rev Log: PIG-270: proper line number for parse errors
Modified: incubator/pig/branches/types/CHANGES.txt incubator/pig/branches/types/src/org/apache/pig/PigServer.java incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlanBuilder.java incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt incubator/pig/branches/types/src/org/apache/pig/tools/grunt/GruntParser.java incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj Modified: incubator/pig/branches/types/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/CHANGES.txt?rev=679166&r1=679165&r2=679166&view=diff ============================================================================== --- incubator/pig/branches/types/CHANGES.txt (original) +++ incubator/pig/branches/types/CHANGES.txt Wed Jul 23 12:35:55 2008 @@ -141,3 +141,5 @@ PIG-258: cleaning up directories on failure (daijy via olgan) PIG-139: command line editing + + PIG-270: proper line number for parse errors Modified: incubator/pig/branches/types/src/org/apache/pig/PigServer.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/PigServer.java?rev=679166&r1=679165&r2=679166&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/PigServer.java (original) +++ incubator/pig/branches/types/src/org/apache/pig/PigServer.java Wed Jul 23 12:35:55 2008 @@ -227,9 +227,11 @@ * * @param query * a Pig Latin expression to be evaluated. + * @param startLine + * line number of the query within the whold script * @throws IOException - */ - public void registerQuery(String query) throws IOException { + */ + public void registerQuery(String query, int startLine) throws IOException { // Bugzilla Bug 1006706 -- ignore empty queries //============================================= if(query != null) { @@ -242,12 +244,16 @@ LogicalPlan lp = null; try { lp = (new LogicalPlanBuilder(pigContext).parse(scope, query, - aliases, opTable, aliasOp)); + aliases, opTable, aliasOp, startLine)); } catch (ParseException e) { throw (IOException) new IOException(e.getMessage()).initCause(e); } } - + + public void registerQuery(String query) throws IOException { + registerQuery(query, 1); + } + public void dumpSchema(String alias) throws IOException{ try { LogicalPlan lp = getPlanFromAlias(alias, "describe"); Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlanBuilder.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlanBuilder.java?rev=679166&r1=679165&r2=679166&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlanBuilder.java (original) +++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlanBuilder.java Wed Jul 23 12:35:55 2008 @@ -45,9 +45,18 @@ Map<OperatorKey, LogicalOperator> opTable, Map<String, LogicalOperator> aliasOp) throws IOException, ParseException { + return parse(scope, query, aliases, opTable, aliasOp, 1); + } + + public LogicalPlan parse(String scope, + String query, + Map<LogicalOperator, LogicalPlan> aliases, + Map<OperatorKey, LogicalOperator> opTable, + Map<String, LogicalOperator> aliasOp, int start) + throws IOException, ParseException { ByteArrayInputStream in = new ByteArrayInputStream(query.getBytes()); //QueryParser parser = new QueryParser(in, pigContext, scope, aliases, opTable); - QueryParser parser = new QueryParser(in, pigContext, scope, aliases, opTable, aliasOp); + QueryParser parser = new QueryParser(in, pigContext, scope, aliases, opTable, aliasOp, start); return parser.Parse(); } Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt?rev=679166&r1=679165&r2=679166&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt (original) +++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt Wed Jul 23 12:35:55 2008 @@ -83,6 +83,17 @@ this.nodeIdGen = NodeIdGenerator.getGenerator(); this.mapAliasOp = aliasOp; } + + public QueryParser(InputStream in, + PigContext pigContext, + String scope, + Map<LogicalOperator, LogicalPlan> aliases, + Map<OperatorKey, LogicalOperator> opTable, + Map<String, LogicalOperator> aliasOp, + int start) { + this(in, pigContext, scope, aliases, opTable, aliasOp); + token_source.input_stream.line = start; + } public class CogroupInput { public LogicalOperator op; Modified: incubator/pig/branches/types/src/org/apache/pig/tools/grunt/GruntParser.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/tools/grunt/GruntParser.java?rev=679166&r1=679165&r2=679166&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/tools/grunt/GruntParser.java (original) +++ incubator/pig/branches/types/src/org/apache/pig/tools/grunt/GruntParser.java Wed Jul 23 12:35:55 2008 @@ -424,10 +424,13 @@ protected void processPig(String cmd) throws IOException { - if (cmd.charAt(cmd.length() - 1) != ';') - mPigServer.registerQuery(cmd + ";"); + int start = 1; + if (!mInteractive) + start = getLineNumber(); + if (cmd.charAt(cmd.length() - 1) != ';') + mPigServer.registerQuery(cmd + ";", start); else - mPigServer.registerQuery(cmd); + mPigServer.registerQuery(cmd, start); } protected void processRemove(String path) throws IOException Modified: incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj?rev=679166&r1=679165&r2=679166&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj (original) +++ incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj Wed Jul 23 12:35:55 2008 @@ -44,6 +44,11 @@ token_source.interactive = interactive; } + public int getLineNumber() + { + return jj_input_stream.getBeginLine(); + } + public void setConsoleReader(ConsoleReader c) { mConsoleReader = c;