Package org.apache.hadoop.hive.ql.processors

Examples of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse


    @Test
    public void testChangeColumns() throws CommandNeedRetryException {
        hcatDriver.run("drop table junit_sem_analysis");
        hcatDriver.run("create table junit_sem_analysis (a int, c string) partitioned by (b string) stored as RCFILE");
        CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis change a a1 int");
        assertEquals(0, response.getResponseCode());

        response = hcatDriver.run("alter table junit_sem_analysis change a1 a string");
        assertEquals(0, response.getResponseCode());

        response = hcatDriver.run("alter table junit_sem_analysis change a a int after c");
        assertEquals(0, response.getResponseCode());
        hcatDriver.run("drop table junit_sem_analysis");
    }
View Full Code Here


    @Test
    public void testAddReplaceCols() throws IOException, MetaException, TException, NoSuchObjectException, CommandNeedRetryException {

        hcatDriver.run("drop table junit_sem_analysis");
        hcatDriver.run("create table junit_sem_analysis (a int, c string) partitioned by (b string) stored as RCFILE");
        CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis replace columns (a1 tinyint)");
        assertEquals(0, response.getResponseCode());

        response = hcatDriver.run("alter table junit_sem_analysis add columns (d tinyint)");
        assertEquals(0, response.getResponseCode());
        assertNull(response.getErrorMessage());

        response = hcatDriver.run("describe extended junit_sem_analysis");
        assertEquals(0, response.getResponseCode());
        Table tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, TBL_NAME);
        List<FieldSchema> cols = tbl.getSd().getCols();
        assertEquals(2, cols.size());
        assertTrue(cols.get(0).equals(new FieldSchema("a1", "tinyint", null)));
        assertTrue(cols.get(1).equals(new FieldSchema("d", "tinyint", null)));
View Full Code Here

public class HCatDriver extends Driver {

    @Override
    public CommandProcessorResponse run(String command) {

        CommandProcessorResponse cpr = null;
        try {
            cpr = super.run(command);
        } catch (CommandNeedRetryException e) {
            return new CommandProcessorResponse(-1, e.toString(), "");
        }

        SessionState ss = SessionState.get();

        if (cpr.getResponseCode() == 0) {
            // Only attempt to do this, if cmd was successful.
            int rc = setFSPermsNGrp(ss);
            cpr = new CommandProcessorResponse(rc);
        }
        // reset conf vars
        ss.getConf().set(HCatConstants.HCAT_CREATE_DB_NAME, "");
        ss.getConf().set(HCatConstants.HCAT_CREATE_TBL_NAME, "");
View Full Code Here

    @Test
    public void testAlterTblClusteredBy() throws CommandNeedRetryException {

        hcatDriver.run("drop table junit_sem_analysis");
        hcatDriver.run("create table junit_sem_analysis (a int) partitioned by (b string) stored as RCFILE");
        CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis clustered by (a) into 7 buckets");
        assertEquals(0, response.getResponseCode());
        hcatDriver.run("drop table junit_sem_analysis");
    }
View Full Code Here

    @Test
    public void testAddPartFail() throws CommandNeedRetryException {

        driver.run("drop table junit_sem_analysis");
        driver.run("create table junit_sem_analysis (a int) partitioned by (b string) stored as RCFILE");
        CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis add partition (b='2') location 'README.txt'");
        assertEquals(0, response.getResponseCode());
        driver.run("drop table junit_sem_analysis");
    }
View Full Code Here

    @Test
    public void testAddPartPass() throws IOException, CommandNeedRetryException {

        hcatDriver.run("drop table junit_sem_analysis");
        hcatDriver.run("create table junit_sem_analysis (a int) partitioned by (b string) stored as RCFILE");
        CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis add partition (b='2') location '" + TEST_DATA_DIR + "'");
        assertEquals(0, response.getResponseCode());
        assertNull(response.getErrorMessage());
        hcatDriver.run("drop table junit_sem_analysis");
    }
View Full Code Here

    @Test
    public void testCTAS() throws CommandNeedRetryException {
        hcatDriver.run("drop table junit_sem_analysis");
        query = "create table junit_sem_analysis (a int) as select * from tbl2";
        CommandProcessorResponse response = hcatDriver.run(query);
        assertEquals(40000, response.getResponseCode());
        assertTrue(response.getErrorMessage().contains("FAILED: SemanticException Operation not supported. Create table as Select is not a valid operation."));
        hcatDriver.run("drop table junit_sem_analysis");
    }
View Full Code Here

    @Test
    public void testStoredAs() throws CommandNeedRetryException {
        hcatDriver.run("drop table junit_sem_analysis");
        query = "create table junit_sem_analysis (a int)";
        CommandProcessorResponse response = hcatDriver.run(query);
        assertEquals(0, response.getResponseCode());
        hcatDriver.run("drop table junit_sem_analysis");
    }
View Full Code Here

    public void testInvalidateNonStringPartition() throws IOException, CommandNeedRetryException {

        hcatDriver.run("drop table junit_sem_analysis");
        query = "create table junit_sem_analysis (a int) partitioned by (b int)  stored as RCFILE";

        CommandProcessorResponse response = hcatDriver.run(query);
        assertEquals(40000, response.getResponseCode());
        assertEquals("FAILED: SemanticException Operation not supported. HCatalog only supports partition columns of type string. For column: b Found type: int",
                response.getErrorMessage());

    }
View Full Code Here

    public void testInvalidateSeqFileStoredAs() throws IOException, CommandNeedRetryException {

        hcatDriver.run("drop table junit_sem_analysis");
        query = "create table junit_sem_analysis (a int) partitioned by (b string)  stored as SEQUENCEFILE";

        CommandProcessorResponse response = hcatDriver.run(query);
        assertEquals(0, response.getResponseCode());

    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse

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.