dengzhhu653 commented on code in PR #5851:
URL: https://github.com/apache/hive/pull/5851#discussion_r2629152936
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -3212,157 +3045,53 @@ private void deleteDataExcludeCmroot(Path path,
boolean ifPurge, boolean shouldE
}
}
- /**
- * Deletes the partitions specified by catName, dbName, tableName. If
checkLocation is true, for
- * locations of partitions which may not be subdirectories of tablePath
checks to make sure the
- * locations are writable.
- *
- * Drops the metadata for each partition.
- *
- * Provides a list of locations of partitions which may not be
subdirectories of tablePath.
- *
- * @param ms RawStore to use for metadata retrieval and delete
- * @param catName The catName
- * @param dbName The dbName
- * @param tableName The tableName
- * @param tablePath The tablePath of which subdirectories does not have to
be checked
- * @param checkLocation Should we check the locations at all
- * @return The list of the Path objects to delete (only in case
checkLocation is true)
- * @throws MetaException
- * @throws IOException
- * @throws NoSuchObjectException
- */
- private List<Path> dropPartitionsAndGetLocations(RawStore ms, String
catName, String dbName,
- String tableName, Path
tablePath, boolean checkLocation)
- throws MetaException, IOException, NoSuchObjectException {
- int batchSize = MetastoreConf.getIntVar(conf,
ConfVars.BATCH_RETRIEVE_OBJECTS_MAX);
- String tableDnsPath = null;
- if (tablePath != null) {
- tableDnsPath = wh.getDnsPath(tablePath).toString();
- }
-
- List<Path> partPaths = new ArrayList<>();
- while (true) {
- List<String> partNames;
- if (checkLocation) {
- Map<String, String> partitionLocations =
ms.getPartitionLocations(catName, dbName, tableName,
- tableDnsPath, batchSize);
- partNames = new ArrayList<>(partitionLocations.keySet());
- for (String partName : partNames) {
- String pathString = partitionLocations.get(partName);
- if (pathString != null) {
- Path partPath = wh.getDnsPath(new Path(pathString));
- // Double check here. Maybe Warehouse.getDnsPath revealed
relationship between the
- // path objects
- if (tableDnsPath == null ||
- !FileUtils.isSubdirectory(tableDnsPath, partPath.toString())) {
- if (!wh.isWritable(partPath.getParent())) {
- throw new MetaException("Table metadata not deleted since the
partition "
- + partName + " has parent location " + partPath.getParent()
- + " which is not writable by " + SecurityUtils.getUser());
- }
- partPaths.add(partPath);
- }
- }
- }
- } else {
- partNames = ms.listPartitionNames(catName, dbName, tableName, (short)
batchSize);
- }
-
- if (partNames == null || partNames.isEmpty()) {
- // No more partitions left to drop. Return with the collected path
list to delete.
- return partPaths;
- }
-
- for (MetaStoreEventListener listener : listeners) {
- //No drop part listener events fired for public listeners
historically, for drop table case.
- //Limiting to internal listeners for now, to avoid unexpected calls
for public listeners.
- if (listener instanceof HMSMetricsListener) {
- for (@SuppressWarnings("unused") String partName : partNames) {
- listener.onDropPartition(null);
- }
- }
- }
-
- ms.dropPartitions(catName, dbName, tableName, partNames);
- }
- }
-
@Override
@Deprecated
public void drop_table(final String dbname, final String name, final boolean
deleteData)
throws NoSuchObjectException, MetaException {
- startFunction("drop_table", ": " + dbname + ":" + name);
- boolean success = false;
- Exception ex = null;
- try {
String[] parsedDbName = parseDbName(dbname, conf);
DropTableRequest dropTableReq = new
DropTableRequest(parsedDbName[DB_NAME], name);
dropTableReq.setDeleteData(deleteData);
dropTableReq.setCatalogName(parsedDbName[CAT_NAME]);
dropTableReq.setDropPartitions(true);
drop_table_req(dropTableReq);
- } catch (Exception e) {
- ex = e;
- throw handleException(e).throwIfInstance(MetaException.class,
NoSuchObjectException.class)
- .convertIfInstance(IOException.class,
MetaException.class).defaultMetaException();
- } finally {
- endFunction("drop_table", success, ex, name);
- }
}
@Override
@Deprecated
public void drop_table_with_environment_context(final String dbname, final
String name, final boolean deleteData,
final EnvironmentContext envContext) throws NoSuchObjectException,
MetaException {
- startFunction("drop_table_with_environment_context", ": " + dbname + ":" +
name);
- boolean success = false;
- Exception ex = null;
- try {
- String[] parsedDbName = parseDbName(dbname, conf);
- DropTableRequest dropTableReq = new
DropTableRequest(parsedDbName[DB_NAME], name);
- dropTableReq.setDeleteData(deleteData);
- dropTableReq.setCatalogName(parsedDbName[CAT_NAME]);
- dropTableReq.setDropPartitions(true);
- dropTableReq.setEnvContext(envContext);
- drop_table_req(dropTableReq);
- success = true;
- } catch (Exception e) {
- ex = e;
- throw handleException(e).throwIfInstance(MetaException.class,
NoSuchObjectException.class)
- .convertIfInstance(IOException.class,
MetaException.class).defaultMetaException();
- } finally {
- endFunction("drop_table_with_environment_context", success, ex, name);
- }
- }
-
- private void drop_table_with_environment_context(final String dbname, final
String name, final boolean deleteData,
- final EnvironmentContext envContext, boolean dropPartitions) throws
MetaException, NoSuchObjectException {
String[] parsedDbName = parseDbName(dbname, conf);
- startTableFunction("drop_table", parsedDbName[CAT_NAME],
parsedDbName[DB_NAME], name);
-
- boolean success = false;
- Exception ex = null;
- try {
- success =
- drop_table_core(getMS(), parsedDbName[CAT_NAME],
parsedDbName[DB_NAME], name, deleteData, envContext, null, dropPartitions);
- } catch (Exception e) {
- ex = e;
- throw handleException(e).throwIfInstance(MetaException.class,
NoSuchObjectException.class)
- .convertIfInstance(IOException.class,
MetaException.class).defaultMetaException();
- } finally {
- endFunction("drop_table", success, ex, name);
- }
+ DropTableRequest dropTableReq = new
DropTableRequest(parsedDbName[DB_NAME], name);
+ dropTableReq.setDeleteData(deleteData);
+ dropTableReq.setCatalogName(parsedDbName[CAT_NAME]);
+ dropTableReq.setDropPartitions(true);
+ dropTableReq.setEnvContext(envContext);
+ drop_table_req(dropTableReq);
}
@Override
- public void drop_table_req(final DropTableRequest dropTableReq) throws
MetaException, NoSuchObjectException {
+ public TableOpResp drop_table_req(DropTableRequest dropTableReq) throws
MetaException, NoSuchObjectException {
startFunction("drop_table_req", ": " + dropTableReq.getTableName());
boolean success = false;
Exception ex = null;
try {
- success = drop_table_core(getMS(), dropTableReq.getCatalogName(),
dropTableReq.getDbName(), dropTableReq.getTableName(),
- dropTableReq.isDeleteData(), dropTableReq.getEnvContext(), null,
dropTableReq.isDropPartitions());
+ TableOperationsHandler<?> tableOp = TableOperationsHandler.offer(this,
dropTableReq);
+ TableOpResp resp = tableOp.toTableOpResp();
Review Comment:
At the same time? one should fail and throw exception I think, let me try
that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]