Package org.apache.pig.builtin

Examples of org.apache.pig.builtin.STRSPLITTOBAG.exec()


    public void testSplitToBag() throws IOException {
        STRSPLITTOBAG bagSplit = new STRSPLITTOBAG();

        //test no delims in input
        Tuple testTuple = Util.buildTuple("1 2 3", "4");
        DataBag outputBag = bagSplit.exec(testTuple);
        assertEquals("No of records split should be 1", 1, outputBag.size());
        assertEquals("Split string should match the input string", "(1 2 3)", outputBag.iterator().next().toString());

        //test default delimiter
        testTuple = Util.buildTuple("1 2 3");
View Full Code Here


        assertEquals("No of records split should be 1", 1, outputBag.size());
        assertEquals("Split string should match the input string", "(1 2 3)", outputBag.iterator().next().toString());

        //test default delimiter
        testTuple = Util.buildTuple("1 2 3");
        outputBag = bagSplit.exec(testTuple);
        String[] assertionArray = {"1", "2", "3"};
        assertEquals("No of record split should be " + assertionArray.length, assertionArray.length, outputBag.size());

        int i = 0;
        for (Tuple t : outputBag) {
View Full Code Here

            i++;
        }

        //test split on specified delimiter
        testTuple = Util.buildTuple("1:2:3", ":");
        outputBag = bagSplit.exec(testTuple);
        assertEquals("No of record split should be " + assertionArray.length, assertionArray.length, outputBag.size());
        i = 0;
        for (Tuple t : outputBag) {
            assertEquals("Assertion tests on split strings", "(" + assertionArray[i] + ")", t.toString());
            i++;
View Full Code Here

            i++;
        }

        // test limiting results with limit
        testTuple = Util.buildTuple("1:2:3", ":", 2);
        outputBag = bagSplit.exec(testTuple);
        assertionArray = new String[]{"1", "2:3"};
        assertEquals("No of record split should be " + assertionArray.length, assertionArray.length, outputBag.size());
        i = 0;
        for (Tuple t : outputBag) {
            assertEquals("Matched records in split results with limit", "(" + assertionArray[i] + ")", t.toString());
View Full Code Here

            i++;
        }

        // test trimming of whitespace
        testTuple = Util.buildTuple("1 2    ");
        outputBag = bagSplit.exec(testTuple);
        assertionArray = new String[]{"1", "2"};
        assertEquals("No of record split should be " + assertionArray.length, assertionArray.length, outputBag.size());
        i = 0;
        for (Tuple t : outputBag) {
            assertEquals("Matched records in split results with trimming of whitespaces", "(" + assertionArray[i] + ")", t.toString());
View Full Code Here

            i++;
        }

        // test forcing null matches with length param
        testTuple = Util.buildTuple("1:2:::", ":", 10);
        outputBag = bagSplit.exec(testTuple);
        assertionArray = new String[]{"1", "2", "", "", ""};
        assertEquals("No of record split should be " + assertionArray.length, assertionArray.length, outputBag.size());
        i = 0;
        for (Tuple t : outputBag) {
            assertEquals("Matched records in split results with forcing null matched with limit", "(" + assertionArray[i] + ")", t.toString());
View Full Code Here

            i++;
        }

        //test wrong schemas
        testTuple = Util.buildTuple(1, 2, 3);
        outputBag = bagSplit.exec(testTuple);
        assertEquals("Wrong Schema checks", null, outputBag);
    }

    @Test
    public void testStartsWith() throws IOException {
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.