You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by th...@apache.org on 2011/04/20 21:14:23 UTC
svn commit: r1095487 - in /pig/trunk: CHANGES.txt
src/org/apache/pig/newplan/logical/visitor/ProjectStarExpander.java
test/org/apache/pig/test/TestProjectRange.java
Author: thejas
Date: Wed Apr 20 19:14:23 2011
New Revision: 1095487
URL: http://svn.apache.org/viewvc?rev=1095487&view=rev
Log:
PIG-1939: order-by statement should support project-range to-end in
any position among the sort columns if input schema is known (thejas)
Modified:
pig/trunk/CHANGES.txt
pig/trunk/src/org/apache/pig/newplan/logical/visitor/ProjectStarExpander.java
pig/trunk/test/org/apache/pig/test/TestProjectRange.java
Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1095487&r1=1095486&r2=1095487&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Apr 20 19:14:23 2011
@@ -170,6 +170,9 @@ PIG-1696: Performance: Use System.arrayc
BUG FIXES
+PIG-1939: order-by statement should support project-range to-end in
+ any position among the sort columns if input schema is known (thejas)
+
PIG-1978: Secondary sort fail when dereferencing two fields inside foreach (daijy)
PIG-1962: Wrong alias assinged to store operator (daijy)
Modified: pig/trunk/src/org/apache/pig/newplan/logical/visitor/ProjectStarExpander.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/newplan/logical/visitor/ProjectStarExpander.java?rev=1095487&r1=1095486&r2=1095487&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/newplan/logical/visitor/ProjectStarExpander.java (original)
+++ pig/trunk/src/org/apache/pig/newplan/logical/visitor/ProjectStarExpander.java Wed Apr 20 19:14:23 2011
@@ -77,14 +77,28 @@ public class ProjectStarExpander extends
if(expPlans.size() != ascOrder.size()){
throw new AssertionError("Size of expPlans and ascorder should be same");
+ }
+
+ for(int i=0; i < expPlans.size(); i++){
+ //expand the plan
+ LogicalExpressionPlan ithExpPlan = expPlans.get(i);
+ List<LogicalExpressionPlan> expandedPlans = expandPlan(ithExpPlan, 0);
+ newExpPlans.addAll(expandedPlans);
+
+ //add corresponding isAsc flags
+ Boolean isAsc = ascOrder.get(i);
+ for(int j=0; j < expandedPlans.size(); j++){
+ newAscOrder.add(isAsc);
+ }
}
//check if there is a project-star-to-end followed by another sort plan
- for(int i=0; i < expPlans.size(); i++){
- ProjectExpression proj = getProjectStar(expPlans.get(i));
+ // in the expanded plans (can happen if there is no input schema)
+ for(int i=0; i < newExpPlans.size(); i++){
+ ProjectExpression proj = getProjectStar(newExpPlans.get(i));
if(proj != null &&
proj.isRangeProject() && proj.getEndCol() == -1 &&
- i != expPlans.size() -1
+ i != newExpPlans.size() -1
){
//because of order by sampler logic limitation, this is not
//supported right now
@@ -97,22 +111,6 @@ public class ProjectStarExpander extends
);
}
}
-
-
- for(int i=0; i < expPlans.size(); i++){
- //expand the plan
- LogicalExpressionPlan ithExpPlan = expPlans.get(i);
- List<LogicalExpressionPlan> expandedPlans = expandPlan(ithExpPlan, 0);
- newExpPlans.addAll(expandedPlans);
-
- //add corresponding isAsc flags
- Boolean isAsc = ascOrder.get(i);
- for(int j=0; j < expandedPlans.size(); j++){
- newAscOrder.add(isAsc);
- }
- }
-
-
sort.setSortColPlans(newExpPlans);
sort.setAscendingCols(newAscOrder);
Modified: pig/trunk/test/org/apache/pig/test/TestProjectRange.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestProjectRange.java?rev=1095487&r1=1095486&r2=1095487&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestProjectRange.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestProjectRange.java Wed Apr 20 19:14:23 2011
@@ -821,7 +821,7 @@ public class TestProjectRange {
query =
" l1 = load '" + INP_FILE_5FIELDS +
"' as (a : int, b : long, c : int, d : int, e : int);"
- + " o = order l1 by b .. c, a DESC, d .. DESC;"
+ + " o = order l1 by b .. c, d .. DESC, a DESC;"
;
compileAndCompareSchema("a : int, b : long, c : int, d : int, e : int", query, "o");