/** * Setup the job * * @param conf Configuration * @throws IOException */ public static void setupJob(Configuration conf) throws IOException { HiveOutputDescription outputDesc = new HiveOutputDescription(); outputDesc.setTableDesc(getHiveTableName()); Map<String, String> partitionValues = ImmutableMap.of("ds", "2013-04-01"); outputDesc.setPartitionValues(partitionValues); LOG.info("Writing to {}", outputDesc); try { HiveApiOutputFormat.initProfile(conf, outputDesc, SampleOutputFormat.SAMPLE_PROFILE_ID); } catch (IOException e) { LOG.error("Failed to initialize profile {}", outputDesc); throw e; } }
@Test public void testOutput() throws Exception { hiveServer.createTable("CREATE TABLE " + hiveTableDesc.getTableName() + " (i1 INT, d1 DOUBLE) " + " ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'"); HiveOutputDescription outputDesc = new HiveOutputDescription(); outputDesc.setTableDesc(hiveTableDesc); HiveTableSchema schema = HiveTableSchemas.lookup(hiveServer.getClient(), null, hiveTableDesc); writeData(outputDesc, schema); HiveInputDescription inputDesc = new HiveInputDescription(); inputDesc.setTableDesc(hiveTableDesc); verifyData(inputDesc); }
@Test public void testOutput() throws Exception { hiveServer.createTable("CREATE TABLE " + hiveTableDesc.getTableName() + " (i1 INT, d1 DOUBLE) " + " ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'"); HiveOutputDescription outputDesc = new HiveOutputDescription(); outputDesc.setTableDesc(hiveTableDesc); HiveTableSchema schema = HiveTableSchemas.lookup(hiveServer.getClient(), null, hiveTableDesc); writeData(outputDesc, schema); HiveInputDescription inputDesc = new HiveInputDescription(); inputDesc.setTableDesc(hiveTableDesc); verifyData(inputDesc); }
@Test public void testOutputWithPartitions() throws Exception { hiveServer.createTable("CREATE TABLE " + hiveTableDesc.getTableName() + " (i1 INT, d1 DOUBLE) " + " PARTITIONED BY (ds STRING) " + " ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'"); HiveOutputDescription outputDesc = new HiveOutputDescription(); outputDesc.putPartitionValue("ds", "foobar"); outputDesc.setTableDesc(hiveTableDesc); HiveTableSchema schema = HiveTableSchemas.lookup(hiveServer.getClient(), null, hiveTableDesc); writeData(outputDesc, schema); HiveInputDescription inputDesc = new HiveInputDescription(); inputDesc.setPartitionFilter("ds='foobar'"); inputDesc.setTableDesc(hiveTableDesc); verifyData(inputDesc); }
@Test public void testOutputWithPartitions() throws Exception { hiveServer.createTable("CREATE TABLE " + hiveTableDesc.getTableName() + " (i1 INT, d1 DOUBLE) " + " PARTITIONED BY (ds STRING) " + " ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'"); HiveOutputDescription outputDesc = new HiveOutputDescription(); outputDesc.putPartitionValue("ds", "foobar"); outputDesc.setTableDesc(hiveTableDesc); HiveTableSchema schema = HiveTableSchemas.lookup(hiveServer.getClient(), null, hiveTableDesc); writeData(outputDesc, schema); HiveInputDescription inputDesc = new HiveInputDescription(); inputDesc.setPartitionFilter("ds='foobar'"); inputDesc.setTableDesc(hiveTableDesc); verifyData(inputDesc); }
outputDesc.setTableDesc(hiveTableDesc);
outputDesc.setTableDesc(hiveTableDesc);
outputDesc.setTableDesc(hiveTableDesc);
outputDesc.setTableDesc(hiveTableDesc);