/** * Drops the partition from its HdfsTable. If the HdfsTable does not exist, an exception is * thrown. If the partition having the given partition spec does not exist, null is returned. * Otherwise, the table with an updated catalog version is returned. */ public Table dropPartition(TableName tableName, List<TPartitionKeyValue> partitionSpec) throws CatalogException { Preconditions.checkNotNull(partitionSpec); Table tbl = getOrLoadTable(tableName.getDb(), tableName.getTbl()); if (tbl == null) { throw new TableNotFoundException("Table not found: " + tbl.getFullName()); } if (!(tbl instanceof HdfsTable)) { throw new CatalogException("Table " + tbl.getFullName() + " is not an Hdfs table"); } HdfsTable hdfsTable = (HdfsTable) tbl; // Locking the catalog here because this accesses hdfsTable's partition list and // updates its catalog version. // TODO: Fix this locking pattern. catalogLock_.writeLock().lock(); try { HdfsPartition hdfsPartition = hdfsTable.dropPartition(partitionSpec); if (hdfsPartition == null) return null; return replaceTableIfUnchanged(hdfsTable, hdfsTable.getCatalogVersion()); } finally { catalogLock_.writeLock().unlock(); } }