Author: sms
Date: Tue May 26 20:24:24 2009
New Revision: 778872

URL: http://svn.apache.org/viewvc?rev=778872&view=rev
Log:
PIG-656: Use of eval or any other keyword in the package hierarchy of a UDF 
causes parse exception (milindb via sms)

Modified:
    hadoop/pig/trunk/CHANGES.txt
    hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
    hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=778872&r1=778871&r2=778872&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Tue May 26 20:24:24 2009
@@ -48,6 +48,9 @@
 
 BUG FIXES
 
+PIG-656: Use of eval or any other keyword in the package hierarchy of a UDF 
causes
+parse exception (milindb via sms)
+
 PIG-814: Make Binstorage more robust when data contains record markers 
(pradeepkth)
 
 PIG-811: Globs with "?" in the pattern are broken in local mode (hagleitn via

Modified: 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt?rev=778872&r1=778871&r2=778872&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt 
(original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt 
Tue May 26 20:24:24 2009
@@ -1028,6 +1028,77 @@
        {log.trace("Exiting NestedExpr"); return op;}
 }
 
+// A keyword or an identifier
+
+Token IdentifierOrReserved() :
+{
+  Token t1; 
+  log.trace("Entering IdentifierOrReserved");
+}
+{
+  (
+  ( t1 = <DEFINE> )
+| (t1 = <LOAD> )
+| (t1 =<FILTER> )
+| (t1 =<FOREACH> )
+| (t1 =<MATCHES> )
+| (t1 =<ORDER> )
+| (t1 =<ARRANGE> )
+| (t1 =<DISTINCT> )
+| (t1 =<COGROUP> )
+| (t1 =<JOIN> )
+| (t1 =<CROSS> )
+| (t1 =<UNION> )
+| (t1 =<SPLIT> )
+| (t1 =<INTO> )
+| (t1 =<IF> )
+| (t1 =<ALL> )
+| (t1 =<ANY> )
+| (t1 =<AS> )
+| (t1 =<BY> )
+| (t1 =<USING> )
+| (t1 =<INNER> )
+| (t1 =<OUTER> )
+| (t1 =<PARALLEL> )
+| (t1 =<GROUP> )
+| (t1 =<AND> )
+| (t1 =<OR> )
+| (t1 =<NOT> )
+| (t1 =<GENERATE> )
+| (t1 =<FLATTEN> )
+| (t1 =<EVAL> )
+| (t1 =<ASC> )
+| (t1 =<DESC> )
+| (t1 =<INT> )
+| (t1 =<LONG> )
+| (t1 =<FLOAT> )
+| (t1 =<DOUBLE> )
+| (t1 =<CHARARRAY> )
+| (t1 =<BYTEARRAY> )
+| (t1 =<BAG> )
+| (t1 =<TUPLE> )
+| (t1 =<MAP> )
+| (t1 =<IS> )
+| (t1 =<NULL> )
+| (t1 =<STREAM> )
+| (t1 =<THROUGH> )
+| (t1 =<STORE> )
+| (t1 =<SHIP> )
+| (t1 =<CACHE> )
+| (t1 =<INPUT> )
+| (t1 =<OUTPUT> )
+| (t1 =<ERROR> )
+| (t1 =<STDIN> )
+| (t1 =<STDOUT> )
+| (t1 =<LIMIT> )
+| (t1 =<SAMPLE> )
+| (t1 =<IDENTIFIER>)
+)
+    {
+      return t1;
+    }
+}
+
 // A reference to an alias
 LogicalOperator Alias(LogicalPlan lp) : 
 {
@@ -2186,7 +2257,7 @@
     {
         lp.add(item);
     }
-|      item = NestedFilter(over,specs,lp, input)        
+|      item = NestedFilter(over,specs,lp, input)
 |      item = NestedSortOrArrange(over,specs,lp, input)
 |      item = NestedDistinct(over,specs,lp, input)     
 |      item = NestedLimit(over,specs,lp, input)        
@@ -3299,8 +3370,8 @@
 String QualifiedFunction() #void : {Token t1;StringBuffer s=new 
StringBuffer(); log.trace("Entering QualifiedFunction");}
 {
        ((t1=<IDENTIFIER> { s.append(t1.image);}
-        (("." t1=<IDENTIFIER> {s.append("." + t1.image);})| 
-         ("$" t1=<IDENTIFIER> {s.append("$" + t1.image);}))*)) 
+        (("." t1=IdentifierOrReserved() {s.append("." + t1.image);})| 
+         ("$" t1=IdentifierOrReserved() {s.append("$" + t1.image);}))*)) 
         {
                log.debug("QualifiedFunction: " + s.toString());
                log.trace("Exiting QualifiedFunction"); 

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java?rev=778872&r1=778871&r2=778872&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java 
(original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java Tue 
May 26 20:24:24 2009
@@ -1893,6 +1893,15 @@
         buildPlan("c = group b by $0;");
     }
 
+    @Test
+    public void testReservedWordsInFunctionNames() {
+        // test that define can contain reserved words are later parts of
+        // fully qualified function name
+        String query = "define FUNC org.apache.iterators.foreach();";
+        LogicalOperator lo = buildPlan(query).getRoots().get(0);
+        assertTrue(lo instanceof LODefine);
+    }
+
 
     @Test
     public void testTokenizeSchema()  throws FrontendException, ParseException 
{


Reply via email to