Package org.apache.pig.impl.logicalLayer

Examples of org.apache.pig.impl.logicalLayer.LOForEach


    @Test
    public void testQueryForeachGenerateStarWithSchema1() throws FrontendException {
        String query = "foreach (load 'a' as (url, hitCount)) generate *, COUNT(*) ;";
        LogicalPlan lp = planTester.buildPlan(query);
       
        LOForEach foreach = (LOForEach)lp.getLeaves().get(0);
        RequiredFields foreachRelevantFields0 = foreach.getRelevantInputs(0, 0).get(0);
        assertTrue(foreachRelevantFields0.getNeedAllFields() == false);
        assertTrue(foreachRelevantFields0.getNeedNoFields() == false);
        assertTrue(foreachRelevantFields0.getFields().size() == 1);
        assertTrue(foreachRelevantFields0.getFields().get(0).first == 0);
        assertTrue(foreachRelevantFields0.getFields().get(0).second == 0);
       
        RequiredFields foreachRelevantFields1 = foreach.getRelevantInputs(0, 1).get(0);
        assertTrue(foreachRelevantFields1.getNeedAllFields() == false);
        assertTrue(foreachRelevantFields1.getNeedNoFields() == false);
        assertTrue(foreachRelevantFields1.getFields().size() == 1);
        assertTrue(foreachRelevantFields1.getFields().get(0).first == 0);
        assertTrue(foreachRelevantFields1.getFields().get(0).second == 1);
       
        RequiredFields foreachRelevantFields2 = foreach.getRelevantInputs(0, 2).get(0);
        assertTrue(foreachRelevantFields2.getNeedAllFields() == true);
        assertTrue(foreachRelevantFields2.getNeedNoFields() == false);
        assertTrue(foreachRelevantFields2.getFields() == null);
    }
View Full Code Here


              return;
            }
            // Limit can be pushed in front of ForEach if it does not have a flatten
            else if (predecessor instanceof LOForEach)
            {
              LOForEach loForEach = (LOForEach)predecessor;
              List<Boolean> mFlatten = loForEach.getFlatten();
              boolean hasFlatten = false;
              for (Boolean b:mFlatten)
                if (b.equals(true)) hasFlatten = true;
             
              // We can safely move LOLimit up
View Full Code Here

                }
            }

            // Build a foreach to insert after the load, giving it a cast for each
            // position that has a type other than byte array.
            LOForEach foreach = new LOForEach(mPlan,
                OperatorKey.genOpKey(scope), genPlans, flattens);
            foreach.setAlias(lo.getAlias());
            // Insert the foreach into the plan and patch up the plan.
            insertAfter(lo, foreach, null);

            rebuildSchemas();
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.LOForEach

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.