Package org.apache.pig

Examples of org.apache.pig.PigServer.executeBatch()


        server.registerQuery("B2 = filter A by a < 2;");
        server.registerQuery("store B2 into '" + PARTITIONED_TABLE + "' using org.apache.hcatalog.pig.HCatStorer('bkt=0');");
        server.registerQuery("C2 = filter A by a >= 2;");
        server.registerQuery("store C2 into '" + PARTITIONED_TABLE + "' using org.apache.hcatalog.pig.HCatStorer('bkt=1');");

        server.executeBatch();

        driver.run("select * from " + PARTITIONED_TABLE);
        ArrayList<String> partitionedTableValuesReadFromHiveDriver = new ArrayList<String>();
        driver.getResults(partitionedTableValuesReadFromHiveDriver);
        assertEquals(basicInputData.size(), partitionedTableValuesReadFromHiveDriver.size());
View Full Code Here


        server.registerQuery("B2 = filter A by a < 2;");
        server.registerQuery("store B2 into '" + PARTITIONED_TABLE + "' using org.apache.hcatalog.pig.HCatStorer('bkt=0');");
        server.registerQuery("C2 = filter A by a >= 2;");
        server.registerQuery("store C2 into '" + PARTITIONED_TABLE + "' using org.apache.hcatalog.pig.HCatStorer('bkt=1');");

        server.executeBatch();

        driver.run("select * from " + BASIC_TABLE);
        ArrayList<String> unpartitionedTableValuesReadFromHiveDriver = new ArrayList<String>();
        driver.getResults(unpartitionedTableValuesReadFromHiveDriver);
        driver.run("select * from " + PARTITIONED_TABLE);
View Full Code Here

        pig.registerQuery("AP = FILTER A BY emp_state == 'AP';");
        pig.registerQuery("STORE TN INTO 'employee' USING " + HCatStorer.class.getName() + "('emp_country=IN,emp_state=TN');");
        pig.registerQuery("STORE KA INTO 'employee' USING " + HCatStorer.class.getName() + "('emp_country=IN,emp_state=KA');");
        pig.registerQuery("STORE KL INTO 'employee' USING " + HCatStorer.class.getName() + "('emp_country=IN,emp_state=KL');");
        pig.registerQuery("STORE AP INTO 'employee' USING " + HCatStorer.class.getName() + "('emp_country=IN,emp_state=AP');");
        pig.executeBatch();
        driver.run("select * from employee");
        ArrayList<String> results = new ArrayList<String>();
        driver.getResults(results);
        Assert.assertEquals(4, results.size());
        Collections.sort(results);
View Full Code Here

        try {
            server.setBatchOn();
            server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (a:int, b:chararray);");
            server.registerQuery("B = foreach A generate a+10, b;");
            server.registerQuery("store B into 'junit_parted' using " + HCatStorer.class.getName() + "('ds=20100101');");
            server.executeBatch();
        } catch (PigException fe) {
            PigException pe = LogUtils.getPigException(fe);
            Assert.assertTrue(pe instanceof FrontendException);
            Assert.assertEquals(PigHCatUtil.PIG_EXCEPTION_CODE, pe.getErrorCode());
            Assert.assertTrue(pe.getMessage().contains("Column name for a field is not specified. Please provide the full schema as an argument to HCatStorer."));
View Full Code Here

        try {
            server.setBatchOn();
            server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (a:int, B:chararray);");
            server.registerQuery("B = foreach A generate a, B;");
            server.registerQuery("store B into 'junit_parted' using " + HCatStorer.class.getName() + "('ds=20100101');");
            server.executeBatch();
        } catch (PigException fe) {
            PigException pe = LogUtils.getPigException(fe);
            Assert.assertTrue(pe instanceof FrontendException);
            Assert.assertEquals(PigHCatUtil.PIG_EXCEPTION_CODE, pe.getErrorCode());
            Assert.assertTrue(pe.getMessage().contains("Column names should all be in lowercase. Invalid name found: B"));
View Full Code Here

        server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (a:int, b:chararray);");
        server.registerQuery("B = filter A by a < 2;");
        server.registerQuery("store B into 'junit_unparted' using " + HCatStorer.class.getName() + "();");
        server.registerQuery("C = filter A by a >= 2;");
        server.registerQuery("store C into 'junit_unparted2' using " + HCatStorer.class.getName() + "();");
        server.executeBatch();

        driver.run("select * from junit_unparted");
        ArrayList<String> res = new ArrayList<String>();
        driver.getResults(res);
        driver.run("select * from junit_unparted2");
View Full Code Here

        HcatTestUtils.createTestDataFile(INPUT_FILE_NAME, input);
        PigServer server = new PigServer(ExecType.LOCAL);
        server.setBatchOn();
        server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (a:int, b:chararray);");
        server.registerQuery("store A into 'default.junit_unparted' using " + HCatStorer.class.getName() + "('');");
        server.executeBatch();

        driver.run("select * from junit_unparted");
        ArrayList<String> res = new ArrayList<String>();
        driver.getResults(res);
        driver.run("drop table junit_unparted");
View Full Code Here

        HcatTestUtils.createTestDataFile(INPUT_FILE_NAME, input);
        PigServer server = new PigServer(ExecType.LOCAL);
        server.setBatchOn();
        server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (a:int, b:chararray);");
        server.registerQuery("store A into 'junit_unparted' using " + HCatStorer.class.getName() + "();");
        server.executeBatch();

        driver.run("select * from junit_unparted");
        ArrayList<String> res = new ArrayList<String>();
        driver.getResults(res);
        driver.run("drop table junit_unparted");
View Full Code Here

        PigServer server = new PigServer(ExecType.LOCAL);
        server.setBatchOn();
        server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (a:int, b:chararray);");
        server.registerQuery("B = filter A by a > 100;");
        server.registerQuery("store B into 'default.junit_unparted' using " + HCatStorer.class.getName() + "('','a:int,b:chararray');");
        server.executeBatch();

        driver.run("select * from junit_unparted");
        ArrayList<String> res = new ArrayList<String>();
        driver.getResults(res);
        driver.run("drop table junit_unparted");
View Full Code Here

        PigServer server = new PigServer(ExecType.LOCAL);
        server.setBatchOn();
        server.registerQuery("A = load '" + INPUT_FILE_NAME + "' as (b:chararray, a:tuple(a1:int), arr_of_struct:bag{mytup:tuple(s1:chararray)}, arr_of_struct2:bag{mytup:tuple(s1:chararray,s2:chararray)}, arr_of_struct3:bag{t3:tuple(s3:chararray)});");
        server.registerQuery("store A into 'default.junit_unparted' using " + HCatStorer.class.getName() + "('','b:chararray, a:tuple(a1:int)," +
            " arr_of_struct:bag{mytup:tuple(s1:chararray)}, arr_of_struct2:bag{mytup:tuple(s1:chararray,s2:chararray)}, arr_of_struct3:bag{t3:tuple(s3:chararray)}');");
        server.executeBatch();

        driver.run("select * from junit_unparted");
        ArrayList<String> res = new ArrayList<String>();
        driver.getResults(res);
        driver.run("drop table junit_unparted");
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.