Author: daijy
Date: Mon Aug 23 21:31:27 2010
New Revision: 988317

URL: http://svn.apache.org/viewvc?rev=988317&view=rev
Log:
PIG-1552: Nested describe failed when the alias is not referred in the first 
foreach inner plan

Modified:
    hadoop/pig/trunk/CHANGES.txt
    hadoop/pig/trunk/src/org/apache/pig/PigServer.java
    hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOForEach.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=988317&r1=988316&r2=988317&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Aug 23 21:31:27 2010
@@ -142,6 +142,8 @@ PIG-1309: Map-side Cogroup (ashutoshc)
 
 BUG FIXES
 
+PIG-1552: Nested describe failed when the alias is not referred in the first 
foreach inner plan (aniket486 via daijy)
+
 PIG-1486: update ant eclipse-files target to include new jar and remove 
contrib dirs from build path (thejas)
 
 PIG-1524: 'Proactive spill count' is misleading (thejas)

Modified: hadoop/pig/trunk/src/org/apache/pig/PigServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/PigServer.java?rev=988317&r1=988316&r2=988317&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/PigServer.java (original)
+++ hadoop/pig/trunk/src/org/apache/pig/PigServer.java Mon Aug 23 21:31:27 2010
@@ -648,7 +648,7 @@ public class PigServer {
         lp = compileLp(alias, false);
         LogicalOperator op = lp.getLeaves().get(0);
         if(op instanceof LOForEach) {
-            return ((LOForEach)op).dumpNestedSchema(nestedAlias);
+            return ((LOForEach)op).dumpNestedSchema(alias, nestedAlias);
         }
         else {
             int errCode = 1001;

Modified: hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOForEach.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOForEach.java?rev=988317&r1=988316&r2=988317&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOForEach.java 
(original)
+++ hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOForEach.java Mon 
Aug 23 21:31:27 2010
@@ -456,7 +456,7 @@ public class LOForEach extends Relationa
         }
     }
     
-    public Schema dumpNestedSchema(String nestedAlias) throws IOException {
+    public Schema dumpNestedSchema(String alias, String nestedAlias) throws 
IOException {
         boolean found = false;
         // To avoid non-deterministic traversal, 
         // we do a traversal from leaf to root with 
ReverseDependencyOrderWalker 
@@ -480,23 +480,27 @@ public class LOForEach extends Relationa
                 if(!(op instanceof LOProject) && 
nestedAlias.equalsIgnoreCase(op.mAlias)) {
                     found = true;
                     // Expression operators do not have any schema
-                    if(!(op instanceof ExpressionOperator)) {
+                    if(op instanceof RelationalOperator) {
                         Schema nestedSc = op.getSchema();
-                        System.out.println(nestedAlias + ": " + 
nestedSc.toString());
+                        if(nestedSc == null) {
+                            System.out.println("Schema for "+ alias+ "::" + 
nestedAlias + " unknown.");
+                        } else {
+                            System.out.println(alias+ "::" + nestedAlias + ": 
" + nestedSc.toString());
+                        }
                         return nestedSc;
                     }
                     else {
                         int errCode = 1113;
-                        String msg = "Unable to describe schema for nested 
expression "+ nestedAlias; 
+                        String msg = "Describe nested expression is not 
supported"; 
                         throw new FrontendException (msg, errCode, 
PigException.INPUT, false, null);
                     }
                 }
             }
-            if(!found) {
-                int errCode = 1114;
-                String msg = "Unable to find schema for nested alias "+ 
nestedAlias; 
-                throw new FrontendException (msg, errCode, PigException.INPUT, 
false, null);
-            }
+        }
+        if(!found) {
+            int errCode = 1114;
+            String msg = "Unable to find schema for nested alias "+ 
nestedAlias; 
+            throw new FrontendException (msg, errCode, PigException.INPUT, 
false, null);
         }
         return null;
     }

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java?rev=988317&r1=988316&r2=988317&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java Mon Aug 23 
21:31:27 2010
@@ -659,7 +659,7 @@ public class TestEvalPipeline2 extends T
         pigServer.registerQuery("A = LOAD 'table_testDescribeNestedAlias' as 
(a0, a1);");
         pigServer.registerQuery("P = GROUP A by a1;");
         // Test RelationalOperator
-        pigServer.registerQuery("B = FOREACH P { D = ORDER A by $0; generate 
D.$0; };");
+        pigServer.registerQuery("B = FOREACH P { D = ORDER A by $0; generate 
group, D.$0; };");
         
         // Test ExpressionOperator - negative test case
         pigServer.registerQuery("C = FOREACH A { D = a0/a1; E=a1/a0; generate 
E as newcol; };");


Reply via email to