public int getLastAccessTime() { return tPartition.getLastAccessTime(); }
public int getLastAccessTime() { return tPartition.getLastAccessTime(); }
private void assertPartitionUnchanged(Partition partition, List<String> testValues, List<String> partCols) throws MetaException { assertFalse(partition.getParameters().containsKey("hmsTestParam001")); List<String> expectedKVPairs = new ArrayList<>(); for (int i = 0; i < partCols.size(); ++i) { expectedKVPairs.add(partCols.get(i) + "=" + testValues.get(i)); } String partPath = expectedKVPairs.stream().collect(joining("/")); assertTrue(partition.getSd().getLocation().equals(metaStore.getWarehouseRoot() + "/testpartdb.db/testparttable/" + partPath)); assertNotEquals(NEW_CREATE_TIME, partition.getCreateTime()); assertNotEquals(NEW_CREATE_TIME, partition.getLastAccessTime()); assertEquals(2, partition.getSd().getCols().size()); }
private void assertPartitionChanged(Partition partition, List<String> testValues, List<String> partCols) throws MetaException { assertEquals("testValue001", partition.getParameters().get("hmsTestParam001")); List<String> expectedKVPairs = new ArrayList<>(); for (int i = 0; i < partCols.size(); ++i) { expectedKVPairs.add(partCols.get(i) + "=" + testValues.get(i)); } String partPath = expectedKVPairs.stream().collect(joining("/")); assertTrue(partition.getSd().getLocation().equals(metaStore.getWarehouseRoot() + "/testpartdb.db/testparttable/" + partPath + "/hh=01")); assertEquals(NEW_CREATE_TIME, partition.getCreateTime()); assertEquals(NEW_CREATE_TIME, partition.getLastAccessTime()); assertEquals(3, partition.getSd().getCols().size()); }
private static void getPartitionMetaDataInformation(StringBuilder tableInfo, Partition part) { formatOutput("Partition Value:", part.getValues().toString(), tableInfo); formatOutput("Database:", part.getTPartition().getDbName(), tableInfo); formatOutput("Table:", part.getTable().getTableName(), tableInfo); formatOutput("CreateTime:", formatDate(part.getTPartition().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(part.getTPartition().getLastAccessTime()), tableInfo); formatOutput("Location:", part.getLocation(), tableInfo); if (part.getTPartition().getParameters().size() > 0) { tableInfo.append("Partition Parameters:").append(LINE_DELIM); displayAllParameters(part.getTPartition().getParameters(), tableInfo); } }
private static void getPartitionMetaDataInformation(StringBuilder tableInfo, Partition part) { formatOutput("Partition Value:", part.getValues().toString(), tableInfo); formatOutput("Database:", part.getTPartition().getDbName(), tableInfo); formatOutput("Table:", part.getTable().getTableName(), tableInfo); formatOutput("CreateTime:", formatDate(part.getTPartition().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(part.getTPartition().getLastAccessTime()), tableInfo); formatOutput("Location:", part.getLocation(), tableInfo); if (part.getTPartition().getParameters().size() > 0) { tableInfo.append("Partition Parameters:").append(LINE_DELIM); displayAllParameters(part.getTPartition().getParameters(), tableInfo); } }
HCatPartition(HCatTable hcatTable, Partition partition) throws HCatException { this.hcatTable = hcatTable; this.tableName = partition.getTableName(); this.dbName = partition.getDbName(); this.createTime = partition.getCreateTime(); this.lastAccessTime = partition.getLastAccessTime(); this.parameters = partition.getParameters(); this.values = partition.getValues(); if (hcatTable != null && partition.getValuesSize() != hcatTable.getPartCols().size()) { throw new HCatException("Mismatched number of partition columns between table:" + hcatTable.getDbName() + "." + hcatTable.getTableName() + " and partition " + partition.getValues()); } this.sd = partition.getSd(); this.columns = getColumns(this.sd); }
/** * Testing * renamePartition(String,String,List(String),Partition) -> * renamePartition(String,String,List(String),Partition). */ @Test public void testRenamePartition() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<List<String>> newValues = new ArrayList<>(); List<String> newVal = Lists.newArrayList("2018", "01", "16"); newValues.addAll(oldValues.subList(0, 3)); newValues.add(newVal); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(newVal); makeTestChangesOnPartition(partToRename); client.renamePartition(DB_NAME, TABLE_NAME, oldValues.get(3), partToRename); List<Partition> newParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); assertPartitionsHaveCorrectValues(newParts, newValues); //Asserting other partition parameters can also be changed, but not the location assertFalse(newParts.get(3).getSd().getLocation().endsWith("hh=01")); assertEquals(3, newParts.get(3).getSd().getCols().size()); assertEquals("testValue001", newParts.get(3).getParameters().get("hmsTestParam001")); assertEquals(NEW_CREATE_TIME, newParts.get(3).getCreateTime()); assertEquals(NEW_CREATE_TIME, newParts.get(3).getLastAccessTime()); assertTrue(client.listPartitions(DB_NAME, TABLE_NAME, oldValues.get(3), (short)-1).isEmpty()); }
public Object getFieldValue(_Fields field) { switch (field) { case VALUES: return getValues(); case DB_NAME: return getDbName(); case TABLE_NAME: return getTableName(); case CREATE_TIME: return getCreateTime(); case LAST_ACCESS_TIME: return getLastAccessTime(); case SD: return getSd(); case PARAMETERS: return getParameters(); case PRIVILEGES: return getPrivileges(); case CAT_NAME: return getCatName(); case WRITE_ID: return getWriteId(); case IS_STATS_COMPLIANT: return isIsStatsCompliant(); case COL_STATS: return getColStats(); } throw new IllegalStateException(); }
hiveDatasetVersion.getPartition().getTable().getTableName(), sourcePartition.getCreateTime(), sourcePartition.getLastAccessTime(), sourcePartition.getSd(), sourcePartition.getParameters());
private void verifyPartitionSharedSD(Table table, String name, List<String> values, int index) throws Exception { Partition part = client.getPartition(table.getDbName(), table.getTableName(), name); Assert.assertNotNull(part); Assert.assertEquals(table.getTableName(), part.getTableName()); List<String> partValues = part.getValues(); Assert.assertEquals(values.size(), partValues.size()); Assert.assertTrue(partValues.containsAll(values)); Assert.assertEquals(table.getDbName(), part.getDbName()); Assert.assertEquals(DEFAULT_CREATE_TIME, part.getLastAccessTime()); Assert.assertEquals(DEFAULT_PARAM_VALUE + index, part.getParameters().get(DEFAULT_PARAM_KEY + index)); Assert.assertFalse(part.getParameters().keySet().contains(table.getParameters().keySet())); StorageDescriptor sd = part.getSd(); Assert.assertNotNull(sd); Assert.assertEquals("TestInputFormat", sd.getInputFormat()); Assert.assertEquals("TestOutputFormat", sd.getOutputFormat()); Assert.assertEquals("sharedSDPartSerde", sd.getSerdeInfo().getName()); Assert.assertEquals("testSDParamValue", sd.getParameters().get("testSDParamKey")); Assert.assertEquals( metaStore.getWarehouseRoot() + "/" + TABLE_NAME + "/sharedSDTest/partwithoutsd" + index, sd.getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(sd.getLocation()))); }
fetched = client.getPartition(DEFAULT_DATABASE_NAME, tableName, Collections.singletonList("a1")); Assert.assertEquals(3L, fetched.getLastAccessTime()); fetched = client.getPartition(DEFAULT_DATABASE_NAME, tableName, Collections.singletonList("a2"));
fetched = client.getPartition(dbName, tableName, Collections.singletonList("a1")); Assert.assertEquals(3L, fetched.getLastAccessTime()); fetched = client.getPartition(dbName, tableName, Collections.singletonList("a2"));
PartitionWithoutSD retPartition = partitionWithoutSDS.get(i); Assert.assertEquals(origPartition.getCreateTime(), retPartition.getCreateTime()); Assert.assertEquals(origPartition.getLastAccessTime(), retPartition.getLastAccessTime()); Assert.assertEquals(origPartition.getSd().getLocation(), sharedSD.getLocation() + retPartition.getRelativePath());
Assert.assertEquals("The DB name in the partition is not correct.", table.getDbName(), part.getDbName()); Assert.assertEquals("The last access time is not correct.", 123456, part.getLastAccessTime()); Assert.assertNotEquals(123456, part.getCreateTime()); Assert.assertEquals(
part.getDbName()); Assert.assertEquals("The last access time is not correct.", DEFAULT_CREATE_TIME, part.getLastAccessTime()); Assert.assertNotEquals(DEFAULT_CREATE_TIME, part.getCreateTime()); Assert.assertEquals(
private void verifyPartition(Partition partition, Table table, List<String> expectedPartValues, String partitionName) throws Exception { Assert.assertEquals(table.getTableName(), partition.getTableName()); Assert.assertEquals(table.getDbName(), partition.getDbName()); Assert.assertEquals(expectedPartValues, partition.getValues()); Assert.assertNotEquals(0, partition.getCreateTime()); Assert.assertEquals(0, partition.getLastAccessTime()); Assert.assertEquals(1, partition.getParameters().size()); Assert.assertTrue(partition.getParameters().containsKey("transient_lastDdlTime")); StorageDescriptor partitionSD = partition.getSd(); Assert.assertEquals(table.getSd().getLocation() + "/" + partitionName, partitionSD.getLocation()); partition.getSd().setLocation(table.getSd().getLocation()); Assert.assertEquals(table.getSd(), partitionSD); Assert.assertTrue(metaStore.isPathExists(new Path(partitionSD.getLocation()))); }
private void verifyPartitionAttributesDefaultValues(Partition partition, String tableLocation) { Assert.assertNotEquals("The partition's last access time should be set.", 0, partition.getLastAccessTime()); Assert.assertNotEquals("The partition's create time should be set.", 0, partition.getCreateTime());
.getCreateTime(), part.getLastAccessTime(), msd, part.getParameters()); return mpart;
client.getPartition(catName, dbName, tableName, Collections.singletonList("a1")); Assert.assertEquals(catName, fetched.getCatName()); Assert.assertEquals(3L, fetched.getLastAccessTime()); fetched = client.getPartition(catName, dbName, tableName, Collections.singletonList("a2"));