@Override public Partition getPartition(String db_name, String tbl_name, List<String> part_vals) throws TException { return getPartition(getDefaultCatalog(conf), db_name, tbl_name, part_vals); }
protected void testFilterForPartition() throws Exception { try { assertNotNull(client.getPartition(DBNAME1, TAB2, "name=value1")); fail("getPartition() should fail with blocking mode"); } catch (NoSuchObjectException e) { // Excepted } try { client.getPartitionsByNames(DBNAME1, TAB2, Lists.newArrayList("name=value1")).size(); } catch (NoSuchObjectException e) { // Excepted } } }
@Override public Partition getPartition(String db, String tableName, String partName) throws TException { return getPartition(getDefaultCatalog(conf), db, tableName, partName); }
/** * Disable filtering at HMS client * By default, the HMS server side filtering is diabled, so we can see HMS client filtering behavior * @throws Exception */ @Test public void testHMSClientWithoutFilter() throws Exception { MetastoreConf.setBoolVar(conf, ConfVars.METASTORE_CLIENT_FILTER_ENABLED, false); DBNAME1 = "db_testHMSClientWithoutFilter_1"; DBNAME2 = "db_testHMSClientWithoutFilter_2"; creatEnv(conf); assertNotNull(client.getTable(DBNAME1, TAB1)); assertEquals(2, client.getTables(DBNAME1, "*").size()); assertEquals(2, client.getAllTables(DBNAME1).size()); assertEquals(1, client.getTables(DBNAME1, TAB2).size()); assertEquals(0, client.getAllTables(DBNAME2).size()); assertNotNull(client.getDatabase(DBNAME1)); assertEquals(2, client.getDatabases("*testHMSClientWithoutFilter*").size()); assertEquals(1, client.getDatabases(DBNAME1).size()); assertNotNull(client.getPartition(DBNAME1, TAB2, "name=value1")); assertEquals(1, client.getPartitionsByNames(DBNAME1, TAB2, Lists.newArrayList("name=value1")).size()); }
try { Table table = new Table(this.client.getTable(dbName, tableName)); apiPartition = this.client.getPartition(dbName, tableName, partitionName); qlPartition = new Partition(table, apiPartition); } catch (Exception e) {
/** * The default configuration should be disable filtering at HMS server * Disable the HMS client side filtering in order to see HMS server filtering behavior * @throws Exception */ @Test public void testHMSServerWithoutFilter() throws Exception { MetastoreConf.setBoolVar(conf, ConfVars.METASTORE_CLIENT_FILTER_ENABLED, false); DBNAME1 = "db_testHMSServerWithoutFilter_1"; DBNAME2 = "db_testHMSServerWithoutFilter_2"; creatEnv(conf); assertNotNull(client.getTable(DBNAME1, TAB1)); assertEquals(2, client.getTables(DBNAME1, "*").size()); assertEquals(2, client.getAllTables(DBNAME1).size()); assertEquals(1, client.getTables(DBNAME1, TAB2).size()); assertEquals(0, client.getAllTables(DBNAME2).size()); assertNotNull(client.getDatabase(DBNAME1)); assertEquals(2, client.getDatabases("*testHMSServerWithoutFilter*").size()); assertEquals(1, client.getDatabases(DBNAME1).size()); assertNotNull(client.getPartition(DBNAME1, TAB2, "name=value1")); assertEquals(1, client.getPartitionsByNames(DBNAME1, TAB2, Lists.newArrayList("name=value1")).size()); }
Partition partObj = hms.getPartition(dbName, tableName, partName); Map<String, String> partSpec = Warehouse.makeSpecFromValues(tableObj.getPartitionKeys(), partObj.getValues());
private List<Partition> createPartitions(String dbName, Table tbl, List<List<String>> values) throws Throwable { int i = 1; List<Partition> partitions = new ArrayList<>(); for(List<String> vals : values) { Partition part = makePartitionObject(dbName, tbl.getTableName(), vals, tbl, "/part"+i); i++; // check if the partition exists (it shouldn't) boolean exceptionThrown = false; try { Partition p = client.getPartition(dbName, tbl.getTableName(), vals); } catch(Exception e) { assertEquals("partition should not have existed", NoSuchObjectException.class, e.getClass()); exceptionThrown = true; } assertTrue("getPartition() should have thrown NoSuchObjectException", exceptionThrown); Partition retp = client.add_partition(part); assertNotNull("Unable to create partition " + part, retp); partitions.add(retp); } return partitions; }
private static void adjust(HiveMetaStoreClient client, Partition part, String dbName, String tblName, boolean isThriftClient) throws TException { Partition part_get = client.getPartition(dbName, tblName, part.getValues()); if (isThriftClient) { part.setCreateTime(part_get.getCreateTime()); part.putToParameters(org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.DDL_TIME, Long.toString(part_get.getCreateTime())); } part.setWriteId(part_get.getWriteId()); }
@Test public void testAlterTblFFpart() throws Exception { driver.run("drop table junit_sem_analysis"); driver.run("create table junit_sem_analysis (a int) partitioned by (b string) stored as TEXTFILE"); driver.run("alter table junit_sem_analysis add partition (b='2010-10-10')"); hcatDriver.run("alter table junit_sem_analysis partition (b='2010-10-10') set fileformat RCFILE"); Table tbl = client.getTable(Warehouse.DEFAULT_DATABASE_NAME, TBL_NAME); assertEquals(TextInputFormat.class.getName(), tbl.getSd().getInputFormat()); assertEquals(HiveIgnoreKeyTextOutputFormat.class.getName(), tbl.getSd().getOutputFormat()); List<String> partVals = new ArrayList<String>(1); partVals.add("2010-10-10"); Partition part = client.getPartition(Warehouse.DEFAULT_DATABASE_NAME, TBL_NAME, partVals); assertEquals(RCFileInputFormat.class.getName(), part.getSd().getInputFormat()); assertEquals(RCFileOutputFormat.class.getName(), part.getSd().getOutputFormat()); hcatDriver.run("drop table junit_sem_analysis"); }
private void publishTest(Job job) throws Exception { HCatOutputFormat hcof = new HCatOutputFormat(); TaskAttemptContext tac = ShimLoader.getHadoopShims().getHCatShim().createTaskAttemptContext( job.getConfiguration(), ShimLoader.getHadoopShims().getHCatShim().createTaskAttemptID()); OutputCommitter committer = hcof.getOutputCommitter(tac); committer.setupJob(job); committer.setupTask(tac); committer.commitTask(tac); committer.commitJob(job); Partition part = client.getPartition(dbName, tblName, Arrays.asList("p1")); assertNotNull(part); StorerInfo storer = InternalUtil.extractStorerInfo(part.getSd(), part.getParameters()); assertEquals(storer.getProperties().get("hcat.testarg"), "testArgValue"); assertTrue(part.getSd().getLocation().contains("p1")); }
pvalues.add("2008-07-01 14:13:12"); pvalues.add("14"); Partition partition = client.getPartition(dbName, tblName, pvalues); assertEquals("Unexpected number of cols", 3, partition.getSd().getCols().size()); assertEquals("Unexpected column name", "new_col", partition.getSd().getCols().get(2).getName()); partition = client.getPartition(dbName, tblName, pvalues); assertEquals("Unexpected number of cols", 3, partition.getSd().getCols().size());
Partition p = client.getPartition(dbName, tblName, vals); } catch(Exception e) { assertEquals("partition should not have existed", assertNotNull("Unable to create partition " + part4, retp4); Partition part_get = client.getPartition(dbName, tblName, part.getValues()); String part4Name = "ds=" + FileUtils.escapePathName("2008-07-03 14:13:12") + "/hr=151"; part_get = client.getPartition(dbName, tblName, partName); assertTrue("Partitions are not the same", part.equals(part_get)); try { String badPartName = "ds=2008-07-01 14%3A13%3A12/hrs=14"; client.getPartition(dbName, tblName, badPartName); } catch(NoSuchObjectException e) { exceptionThrown = true; Partition part5 = client.getPartition(dbName, tblName, part.getValues()); assertTrue("Append partition by name failed", part5.getValues().equals(vals)); Path part5Path = new Path(part5.getSd().getLocation());
Partition part = msc.getPartition("hive2038", "tmptbl", "b=2011"); Partition partAdded = partEvent.getPartitionIterator().next(); partAdded.setWriteId(part.getWriteId()); Partition origP = msc.getPartition(dbName, tblName, "b=2011");
Partition part2 = client.getPartition(dbName, viewName, part.getValues()); Partition part3 = client.getPartition(dbName, viewName, part.getValues()); assertEquals("couldn't view alter partition", part3.getParameters().get( "a"), "b");
Partition p = client.getPartition(dbName, tblName, vals); } catch(Exception e) { assertEquals("partition should not have existed", Partition part3 = client.getPartition(dbName, tblName, tmp_vals); assertEquals("couldn't rename partition", part3.getParameters().get( "retention"), "10"); Partition p = client.getPartition(dbName, tblName, tmp_vals); } catch(Exception e) { assertEquals("partition should not have existed", part3 = client.getPartition(dbName, tblName, vals); assertEquals("couldn't rename partition", part3.getParameters().get( "retention"), "10");
msc.getPartition("hive3524", tblName, "b=2012"); } catch (Exception e2) {
Partition part2 = client.getPartition(dbName, tblName, part.getValues()); client.alter_partition(dbName, tblName, part2, null); Partition part3 = client.getPartition(dbName, tblName, part.getValues()); assertEquals("couldn't alter partition", part3.getParameters().get( "retention"), "10");