Examples of LOFilter


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

        lpTester.typeCheckPlan(lp);
        lpTester.optimizePlan(lp);
        assertEquals("checking partition filter:",            
                    "((mrkt == 'us') and (srcid == 10))",
                    TestLoader.partFilter.toString());
        LOFilter filter = (LOFilter) lp.getLeaves().get(0);
        String actual = PColFilterExtractor.getExpression(
                (ExpressionOperator) filter.getComparisonPlan().
                getLeaves().get(0)).
                toString().toLowerCase();
        assertEquals("checking trimmed filter expression:",
                "((age >= 20) and (f3 == 15))", actual);
    }
View Full Code Here

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

    //// helper methods ///////
   
    private PColFilterExtractor test(LogicalPlan lp, List<String> partitionCols,
            String expPartFilterString, String expFilterString)
    throws FrontendException {
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        PColFilterExtractor pColExtractor = new PColFilterExtractor(
                filter.getComparisonPlan(), partitionCols);
        pColExtractor.visit();
       
        if(expPartFilterString == null) {
            assertEquals("Checking partition column filter:", null,
                    pColExtractor.getPColCondition());
        } else  {
            assertEquals("Checking partition column filter:",
                    expPartFilterString.toLowerCase(),
                    pColExtractor.getPColCondition().toString().toLowerCase());  
        }
       
        if(expFilterString == null) {
            assertTrue("Check that filter can be removed:",
                    pColExtractor.isFilterRemovable());
        } else {
            String actual = PColFilterExtractor.getExpression(
                                (ExpressionOperator) filter.getComparisonPlan().
                                getLeaves().get(0)).
                                toString().toLowerCase();
            assertEquals("checking trimmed filter expression:", expFilterString,
                    actual);
        }
View Full Code Here

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

        return pColExtractor;
    }
   
    private void negativeTest(LogicalPlan lp, List<String> partitionCols,
            int expectedErrorCode) {
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        PColFilterExtractor pColExtractor = new PColFilterExtractor(
                filter.getComparisonPlan(), partitionCols);
        try {
            pColExtractor.visit();
        } catch(Exception e) {
            assertEquals("Checking if exception has right error code",
                    expectedErrorCode, LogUtils.getPigException(e).getErrorCode());
View Full Code Here

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

        lpTester.typeCheckPlan(lp);
        lpTester.optimizePlan(lp);
        assertEquals("checking partition filter:",            
                    "((mrkt == 'us') and (srcid == 10))",
                    TestLoader.partFilter.toString());
        LOFilter filter = (LOFilter) lp.getLeaves().get(0);
        String actual = PColFilterExtractor.getExpression(
                (ExpressionOperator) filter.getComparisonPlan().
                getLeaves().get(0)).
                toString().toLowerCase();
        assertEquals("checking trimmed filter expression:",
                "((f5 >= 20) and (f3 == 15))", actual);
    }
View Full Code Here

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

        lpTester.typeCheckPlan(lp);
        lpTester.optimizePlan(lp);
        assertEquals("checking partition filter:",            
                    null,
                    TestLoader.partFilter);
        LOFilter filter = (LOFilter) lp.getLeaves().get(0);
        String actual = PColFilterExtractor.getExpression(
                (ExpressionOperator) filter.getComparisonPlan().
                getLeaves().get(0)).
                toString().toLowerCase();
        assertEquals("checking trimmed filter expression:",
                "(((f5 >= 20) and (f2 == 'us')) and (f3 == 15))", actual);
    }
View Full Code Here

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

        lpTester.typeCheckPlan(lp);
        lpTester.optimizePlan(lp);
        assertEquals("checking partition filter:",            
                    "((mrkt == 'us') and (srcid == 10))",
                    TestLoader.partFilter.toString());
        LOFilter filter = (LOFilter) lp.getLeaves().get(0);
        String actual = PColFilterExtractor.getExpression(
                (ExpressionOperator) filter.getComparisonPlan().
                getLeaves().get(0)).
                toString().toLowerCase();
        assertEquals("checking trimmed filter expression:",
                "((age >= 20) and (f3 == 15))", actual);
    }
View Full Code Here

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

    //// helper methods ///////
   
    private PColFilterExtractor test(LogicalPlan lp, List<String> partitionCols,
            String expPartFilterString, String expFilterString)
    throws FrontendException {
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        PColFilterExtractor pColExtractor = new PColFilterExtractor(
                filter.getComparisonPlan(), partitionCols);
        pColExtractor.visit();
       
        if(expPartFilterString == null) {
            assertEquals("Checking partition column filter:", null,
                    pColExtractor.getPColCondition());
        } else  {
            assertEquals("Checking partition column filter:",
                    expPartFilterString.toLowerCase(),
                    pColExtractor.getPColCondition().toString().toLowerCase());  
        }
       
        if(expFilterString == null) {
            assertTrue("Check that filter can be removed:",
                    pColExtractor.isFilterRemovable());
        } else {
            String actual = PColFilterExtractor.getExpression(
                                (ExpressionOperator) filter.getComparisonPlan().
                                getLeaves().get(0)).
                                toString().toLowerCase();
            assertEquals("checking trimmed filter expression:", expFilterString,
                    actual);
        }
View Full Code Here

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

        return pColExtractor;
    }
   
    private void negativeTest(LogicalPlan lp, List<String> partitionCols,
            int expectedErrorCode) {
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        PColFilterExtractor pColExtractor = new PColFilterExtractor(
                filter.getComparisonPlan(), partitionCols);
        try {
            pColExtractor.visit();
        } catch(Exception e) {
            assertEquals("Checking if exception has right error code",
                    expectedErrorCode, LogUtils.getPigException(e).getErrorCode());
View Full Code Here

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

    public void testQueryFilterNoSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = filter a by $1 == '3';");
       
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        List<RequiredFields> filterRelevantFields0 = filter.getRelevantInputs(0, 0);
        assertTrue(filterRelevantFields0.get(0).getFields().size() == 1);
        assertTrue(filterRelevantFields0.get(0).getNeedAllFields()==false);
        assertTrue(filterRelevantFields0.get(0).getNeedAllFields()==false);
        assertTrue(filterRelevantFields0.get(0).getFields().contains(new Pair<Integer, Integer>(0, 0)));
    }
View Full Code Here

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

    @Test
    public void testQueryFilterWithSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        LogicalPlan lp = planTester.buildPlan("b = filter a by $1 == '3';");
       
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        List<RequiredFields> filterRelevantFields0 = filter.getRelevantInputs(0, 0);
        assertTrue(filterRelevantFields0.get(0).getFields().size() == 1);
        assertTrue(filterRelevantFields0.get(0).getNeedAllFields()==false);
        assertTrue(filterRelevantFields0.get(0).getNeedAllFields()==false);
        assertTrue(filterRelevantFields0.get(0).getFields().contains(new Pair<Integer, Integer>(0, 0)));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.