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

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


    public void testInvalidateTextFileStoredAs() throws IOException, CommandNeedRetryException {

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

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

    }
View Full Code Here


    public void testInvalidateClusteredBy() throws IOException, CommandNeedRetryException {

        hcatDriver.run("drop table junit_sem_analysis");
        query = "create table junit_sem_analysis (a int) partitioned by (b string) clustered by (a) into 10 buckets stored as TEXTFILE";

        CommandProcessorResponse response = hcatDriver.run(query);
        assertEquals(0, response.getResponseCode());
    }
View Full Code Here

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

        driver.run(query);
        query = "create table like_table like junit_sem_analysis";
        CommandProcessorResponse response = hcatDriver.run(query);
        assertEquals(0, response.getResponseCode());
    }
View Full Code Here

        hcatDriver.run(query);
        String likeTbl = "like_table";
        hcatDriver.run("drop table " + likeTbl);
        query = "create table like_table like junit_sem_analysis";
        CommandProcessorResponse resp = hcatDriver.run(query);
        assertEquals(0, resp.getResponseCode());
//    Table tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, likeTbl);
//    assertEquals(likeTbl,tbl.getTableName());
//    List<FieldSchema> cols = tbl.getSd().getCols();
//    assertEquals(1, cols.size());
//    assertEquals(new FieldSchema("a", "int", null), cols.get(0));
View Full Code Here

            createTable = createTable + "partitioned by (" + partitionedBy + ") ";
        }
        createTable = createTable + "stored as RCFILE tblproperties('hcat.isd'='org.apache.hcatalog.rcfile.RCFileInputDriver'," +
            "'hcat.osd'='org.apache.hcatalog.rcfile.RCFileOutputDriver') ";
        LOG.info("Creating table:\n {}", createTable);
        CommandProcessorResponse result = driver.run(createTable);
        int retCode = result.getResponseCode();
        if (retCode != 0) {
            throw new IOException("Failed to create table. [" + createTable + "], return code from hive driver : [" + retCode + " " + result.getErrorMessage() + "]");
        }
    }
View Full Code Here

            sb.append(':');
            sb.append(port);
        }

        hcatDriver.run("drop table test_table");
        CommandProcessorResponse response = hcatDriver
            .run("create table test_table(key int, value string) STORED BY " +
                "'org.apache.hcatalog.hbase.HBaseHCatStorageHandler'"
                + "TBLPROPERTIES ('hbase.columns.mapping'=':key,cf1:val')");

        assertEquals(0, response.getResponseCode());

        HBaseAdmin hAdmin = new HBaseAdmin(getHbaseConf());
        boolean doesTableExist = hAdmin.tableExists("test_table");
        assertTrue(doesTableExist);
View Full Code Here

        String tableQuery = "CREATE TABLE " + databaseName + "." + tableName
            + "(key string, testqualifier1 string, testqualifier2 string) STORED BY " +
            "'org.apache.hcatalog.hbase.HBaseHCatStorageHandler'"
            + "TBLPROPERTIES ('hbase.columns.mapping'=':key,testFamily:testQualifier1,testFamily:testQualifier2')";

        CommandProcessorResponse responseOne = hcatDriver.run(dbquery);
        assertEquals(0, responseOne.getResponseCode());
        CommandProcessorResponse responseTwo = hcatDriver.run(tableQuery);
        assertEquals(0, responseTwo.getResponseCode());

        HBaseAdmin hAdmin = new HBaseAdmin(getHbaseConf());
        boolean doesTableExist = hAdmin.tableExists(hbaseTableName);
        assertTrue(doesTableExist);

        populateHBaseTable(hbaseTableName, 5);
        Configuration conf = new Configuration(hcatConf);
        conf.set(HCatConstants.HCAT_KEY_HIVE_CONF,
            HCatUtil.serialize(getHiveConf().getAllProperties()));

        // output settings
        Path outputDir = new Path(getTestDir(), "mapred/testHbaseTableMRRead");
        FileSystem fs = getFileSystem();
        if (fs.exists(outputDir)) {
            fs.delete(outputDir, true);
        }
        // create job
        Job job = new Job(conf, "hbase-mr-read-test");
        job.setJarByClass(this.getClass());
        job.setMapperClass(MapReadHTable.class);
        MapReadHTable.resetCounters();

        job.setInputFormatClass(HCatInputFormat.class);
        HCatInputFormat.setInput(job.getConfiguration(), databaseName, tableName);
        job.setOutputFormatClass(TextOutputFormat.class);
        TextOutputFormat.setOutputPath(job, outputDir);
        job.setMapOutputKeyClass(BytesWritable.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(BytesWritable.class);
        job.setOutputValueClass(Text.class);
        job.setNumReduceTasks(0);
        assertTrue(job.waitForCompletion(true));
        // Note: These asserts only works in case of LocalJobRunner as they run in same jvm.
        // If using MiniMRCluster, the tests will have to be modified.
        assertFalse(MapReadHTable.error);
        assertEquals(MapReadHTable.count, 1);

        String dropTableQuery = "DROP TABLE " + hbaseTableName;
        CommandProcessorResponse responseThree = hcatDriver.run(dropTableQuery);
        assertEquals(0, responseThree.getResponseCode());

        boolean isHbaseTableThere = hAdmin.tableExists(hbaseTableName);
        assertFalse(isHbaseTableThere);

        String dropDB = "DROP DATABASE " + databaseName;
        CommandProcessorResponse responseFour = hcatDriver.run(dropDB);
        assertEquals(0, responseFour.getResponseCode());
    }
View Full Code Here

            + "'org.apache.hcatalog.hbase.HBaseHCatStorageHandler'"
            + "TBLPROPERTIES ('hbase.columns.mapping'="
            + "':key,testFamily:testQualifier1,testFamily:testQualifier2',"
            + "'hbase.table.name'='" + hbaseTableName + "')";

        CommandProcessorResponse responseTwo = hcatDriver.run(tableQuery);
        assertEquals(0, responseTwo.getResponseCode());

        HBaseAdmin hAdmin = new HBaseAdmin(getHbaseConf());
        boolean doesTableExist = hAdmin.tableExists(hbaseTableName);
        assertTrue(doesTableExist);

        populateHBaseTable(hbaseTableName, 5);

        Configuration conf = new Configuration(hcatConf);
        conf.set(HCatConstants.HCAT_KEY_HIVE_CONF,
            HCatUtil.serialize(getHiveConf().getAllProperties()));

        // output settings
        Path outputDir = new Path(getTestDir(), "mapred/testHBaseTableProjectionReadMR");
        FileSystem fs = getFileSystem();
        if (fs.exists(outputDir)) {
            fs.delete(outputDir, true);
        }
        // create job
        Job job = new Job(conf, "hbase-column-projection");
        job.setJarByClass(this.getClass());
        job.setMapperClass(MapReadProjHTable.class);
        job.setInputFormatClass(HCatInputFormat.class);
        HCatInputFormat.setOutputSchema(job, getProjectionSchema());
        HCatInputFormat.setInput(job, MetaStoreUtils.DEFAULT_DATABASE_NAME, tableName);
        job.setOutputFormatClass(TextOutputFormat.class);
        TextOutputFormat.setOutputPath(job, outputDir);
        job.setMapOutputKeyClass(BytesWritable.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(BytesWritable.class);
        job.setOutputValueClass(Text.class);
        job.setNumReduceTasks(0);
        assertTrue(job.waitForCompletion(true));
        assertFalse(MapReadProjHTable.error);
        assertEquals(MapReadProjHTable.count, 1);

        String dropTableQuery = "DROP TABLE " + tableName;
        CommandProcessorResponse responseThree = hcatDriver.run(dropTableQuery);
        assertEquals(0, responseThree.getResponseCode());

        boolean isHbaseTableThere = hAdmin.tableExists(hbaseTableName);
        assertFalse(isHbaseTableThere);
    }
View Full Code Here

            + "(key string, testqualifier1 string, testqualifier2 string) STORED BY " +
            "'org.apache.hcatalog.hbase.HBaseHCatStorageHandler'"
            + "TBLPROPERTIES ('hbase.columns.mapping'=':key," +
            "testFamily:testQualifier1,testFamily:testQualifier2')";

        CommandProcessorResponse responseTwo = hcatDriver.run(tableQuery);
        assertEquals(0, responseTwo.getResponseCode());

        HBaseAdmin hAdmin = new HBaseAdmin(getHbaseConf());
        boolean doesTableExist = hAdmin.tableExists(tableName);
        assertTrue(doesTableExist);

        populateHBaseTable(tableName, 5);

        Configuration conf = new Configuration(hcatConf);
        conf.set(HCatConstants.HCAT_KEY_HIVE_CONF,
            HCatUtil.serialize(getHiveConf().getAllProperties()));

        // output settings
        Path outputDir = new Path(getTestDir(), "mapred/testHBaseTableProjectionReadMR");
        FileSystem fs = getFileSystem();
        if (fs.exists(outputDir)) {
            fs.delete(outputDir, true);
        }
        // create job
        JobConf job = new JobConf(conf);
        job.setJobName("hbase-scan-column");
        job.setJarByClass(this.getClass());
        job.setMapperClass(MapReadProjectionHTable.class);
        job.setInputFormat(HBaseInputFormat.class);

        //Configure projection schema
        job.set(HCatConstants.HCAT_KEY_OUTPUT_SCHEMA, HCatUtil.serialize(getProjectionSchema()));
        Job newJob = new Job(job);
        HCatInputFormat.setInput(newJob, MetaStoreUtils.DEFAULT_DATABASE_NAME, tableName);
        String inputJobString = newJob.getConfiguration().get(HCatConstants.HCAT_KEY_JOB_INFO);
        InputJobInfo info = (InputJobInfo) HCatUtil.deserialize(inputJobString);
        job.set(HCatConstants.HCAT_KEY_JOB_INFO, inputJobString);
        for (PartInfo partinfo : info.getPartitions()) {
            for (Entry<String, String> entry : partinfo.getJobProperties().entrySet())
                job.set(entry.getKey(), entry.getValue());
        }
        assertEquals("testFamily:testQualifier1", job.get(TableInputFormat.SCAN_COLUMNS));

        job.setOutputFormat(org.apache.hadoop.mapred.TextOutputFormat.class);
        org.apache.hadoop.mapred.TextOutputFormat.setOutputPath(job, outputDir);
        job.setMapOutputKeyClass(BytesWritable.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(BytesWritable.class);
        job.setOutputValueClass(Text.class);
        job.setNumReduceTasks(0);

        RunningJob runJob = JobClient.runJob(job);
        runJob.waitForCompletion();
        assertTrue(runJob.isSuccessful());
        assertFalse(MapReadProjHTable.error);
        assertEquals(MapReadProjHTable.count, 1);

        String dropTableQuery = "DROP TABLE " + tableName;
        CommandProcessorResponse responseThree = hcatDriver.run(dropTableQuery);
        assertEquals(0, responseThree.getResponseCode());

        boolean isHbaseTableThere = hAdmin.tableExists(tableName);
        assertFalse(isHbaseTableThere);
    }
View Full Code Here

            + "(key string, testqualifier1 string, testqualifier2 string) STORED BY " +
            "'org.apache.hcatalog.hbase.HBaseHCatStorageHandler'"
            + "TBLPROPERTIES ('hbase.columns.mapping'=':key," +
            "testFamily:testQualifier1,testFamily:testQualifier2')";

        CommandProcessorResponse responseTwo = hcatDriver.run(tableQuery);
        assertEquals(0, responseTwo.getResponseCode());

        HBaseAdmin hAdmin = new HBaseAdmin(getHbaseConf());
        boolean doesTableExist = hAdmin.tableExists(tableName);
        assertTrue(doesTableExist);

        populateHBaseTable(tableName, 5);
        populateHBaseTableQualifier1(tableName, 6, false);
        populateHBaseTableQualifier1(tableName, 7, false);

        Configuration conf = new Configuration(hcatConf);
        conf.set(HCatConstants.HCAT_KEY_HIVE_CONF,
            HCatUtil.serialize(getHiveConf().getAllProperties()));

        Path outputDir = new Path(getTestDir(), "mapred/testHBaseTableIgnoreAbortedTransactions");
        FileSystem fs = getFileSystem();
        if (fs.exists(outputDir)) {
            fs.delete(outputDir, true);
        }
        Job job = new Job(conf, "hbase-aborted-transaction");
        job.setJarByClass(this.getClass());
        job.setMapperClass(MapReadHTable.class);
        MapReadHTable.resetCounters();
        job.setInputFormatClass(HCatInputFormat.class);
        HCatInputFormat.setInput(job, MetaStoreUtils.DEFAULT_DATABASE_NAME, tableName);
        job.setOutputFormatClass(TextOutputFormat.class);
        TextOutputFormat.setOutputPath(job, outputDir);
        job.setMapOutputKeyClass(BytesWritable.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(BytesWritable.class);
        job.setOutputValueClass(Text.class);
        job.setNumReduceTasks(0);
        assertTrue(job.waitForCompletion(true));
        // Verify that the records do not contain aborted transaction
        // revisions 6 and 7 for testFamily:testQualifier1 and
        // fetches revision 5 for both testQualifier1 and testQualifier2
        assertFalse(MapReadHTable.error);
        assertEquals(1, MapReadHTable.count);

        String dropTableQuery = "DROP TABLE " + tableName;
        CommandProcessorResponse responseThree = hcatDriver.run(dropTableQuery);
        assertEquals(0, responseThree.getResponseCode());

        boolean isHbaseTableThere = hAdmin.tableExists(tableName);
        assertFalse(isHbaseTableThere);
    }
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.