Author: olga Date: Fri Sep 19 15:42:52 2008 New Revision: 697273 URL: http://svn.apache.org/viewvc?rev=697273&view=rev Log: PIG-439: disallow alias renaming
Modified: incubator/pig/branches/types/CHANGES.txt incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java Modified: incubator/pig/branches/types/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/CHANGES.txt?rev=697273&r1=697272&r2=697273&view=diff ============================================================================== --- incubator/pig/branches/types/CHANGES.txt (original) +++ incubator/pig/branches/types/CHANGES.txt Fri Sep 19 15:42:52 2008 @@ -213,4 +213,4 @@ PIG-364: Limit return incorrect records when we use multiple reducer (daijy via olgan) - + PIG-439: disallow alias renaming 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=697273&r1=697272&r2=697273&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 Fri Sep 19 15:42:52 2008 @@ -742,13 +742,20 @@ LogicalPlan Parse() : { LogicalOperator root = null; - Token t1; + Token t1; + Token t2; LogicalPlan lp = new LogicalPlan(); log.trace("Entering Parse"); } { ( - LOOKAHEAD(2) + LOOKAHEAD(3) + // For now don't allow A = B; kind of statements - this should + // be fixed and allowed in the future + (t1 = <IDENTIFIER> "=" t2 = <IDENTIFIER> [ <AS> "(" TupleSchema() ")" ] ";" { + throw new ParseException( + "Currently PIG does not support assigning an existing relation (" + t1.image + ") to another alias (" + t2.image + ")");}) +| LOOKAHEAD(2) (t1 = <IDENTIFIER> "=" root = Expr(lp) ";" {root.setAlias(t1.image); addAlias(t1.image, root);}) | (root = Expr(lp) ";") | (<SPLIT> root = SplitClause(lp) ";") Modified: incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java?rev=697273&r1=697272&r2=697273&view=diff ============================================================================== --- incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java (original) +++ incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java Fri Sep 19 15:42:52 2008 @@ -566,10 +566,19 @@ } @Test - public void testQuery41() { + public void testQueryFail41() { buildPlan("a = load 'a';"); - buildPlan("b = a as (host,url);"); - buildPlan("foreach b generate host;"); + try { + buildPlan("b = a as (host,url);"); + } catch (AssertionFailedError e) { + assertTrue(e.getMessage().contains("Currently PIG does not support assigning an existing relation")); + } + // TODO + // the following statement was earlier present + // eventually when we do allow assignments of the form + // above, we should test with the line below + // uncommented + //buildPlan("foreach b generate host;"); } @Test