List<HCatPartition> partitions = client.getPartitions(dbName, tableName); assertEquals("Unexpected number of partitions.", 1, partitions.size()); assertArrayEquals("Mismatched partition.", new String[]{"2011_12_31", "AB"}, partitions.get(0).getValues().toArray());
partialPartitionSpec.put("dt", "2012_01_01"); List<HCatPartition> partitions = client.getPartitions(dbName, tableName, partialPartitionSpec); assertEquals("Unexpected number of partitions.", 3, partitions.size()); assertArrayEquals("Mismatched partition.", new String[]{"2012_01_01", "AB"}, partitions.get(0).getValues().toArray());
1, sourceMetaStore().getPartitions(dbName, tableName).size()); List<HCatPartition> sourcePartitions = sourceMetaStore().getPartitions(dbName, tableName); assertEquals("Unexpected number of source partitions.", 2, sourcePartitions.size()); List<HCatPartition> targetPartitions = targetMetaStore().getPartitions(dbName, tableName);
1, sourceMetaStore().getPartitions(dbName, tableName).size());
public List<HCatPartition> getPartitions(String db, String table, String partitionSpec) throws Exception { String[] parts = partitionSpec.split(HCatURI.PARTITION_SEPARATOR); Map<String, String> partitions = new HashMap<String, String>(); for (String part : parts) { String[] split = part.split("="); partitions.put(split[0], split[1]); } return hcatClient.getPartitions(db, table, partitions); }
private boolean exists(URI uri, HCatClient client, boolean closeClient) throws HCatAccessorException { try { boolean flag; HCatURI hcatURI = new HCatURI(uri.toString()); if (!hcatURI.getPartitionMap().isEmpty()) { List<HCatPartition> partitions = client.getPartitions(hcatURI.getDb(), hcatURI.getTable(), hcatURI.getPartitionMap()); flag = partitions != null && !partitions.isEmpty(); } else { List<String> tables = client.listTableNamesByPattern(hcatURI.getDb(), hcatURI.getTable()); flag = tables != null && !tables.isEmpty(); } return (flag); } catch (ConnectionFailureException e) { throw new HCatAccessorException(ErrorCode.E1501, e); } catch (HCatException e) { throw new HCatAccessorException(ErrorCode.E0902, e); } catch (URISyntaxException e) { throw new HCatAccessorException(ErrorCode.E0902, e); } finally { closeQuietly(client, null, closeClient); } }
private boolean exists(URI uri, HCatClient client, boolean closeClient) throws HCatAccessorException { try { boolean flag; HCatURI hcatURI = new HCatURI(uri.toString()); if (!hcatURI.getPartitionMap().isEmpty()) { List<HCatPartition> partitions = client.getPartitions(hcatURI.getDb(), hcatURI.getTable(), hcatURI.getPartitionMap()); flag = partitions != null && !partitions.isEmpty(); } else { List<String> tables = client.listTableNamesByPattern(hcatURI.getDb(), hcatURI.getTable()); flag = tables != null && !tables.isEmpty(); } return (flag); } catch (ConnectionFailureException e) { throw new HCatAccessorException(ErrorCode.E1501, e); } catch (HCatException e) { throw new HCatAccessorException(ErrorCode.E0902, e); } catch (URISyntaxException e) { throw new HCatAccessorException(ErrorCode.E0902, e); } finally { closeQuietly(client, null, closeClient); } }