private List<String> getPartitionNamesViaOrm(String catName, String dbName, String tblName,
      ExpressionTree tree, String order, Integer maxParts, boolean isValidatedFilter,
      List<FieldSchema> partitionKeys) throws MetaException {
    Map<String, Object> params = new HashMap<String, Object>();
    String jdoFilter = makeQueryFilterString(catName, dbName, tblName, tree,
        params, isValidatedFilter, partitionKeys);
    if (jdoFilter == null) {
      assert !isValidatedFilter;
      throw new MetaException("Failed to generate filter.");
    }

    try (QueryWrapper query = new QueryWrapper(pm.newQuery(
        "select partitionName from org.apache.hadoop.hive.metastore.model.MPartition"))) {
      query.setFilter(jdoFilter);
      List<Object[]> orderSpecs = MetaStoreUtils.makeOrderSpecs(order);
      StringBuilder builder = new StringBuilder();
      for (Object[] spec : orderSpecs) {
        // TODO: order by casted value if the type of partition key is not string
        builder.append("values.get(").append(spec[0]).append(") ").append(spec[1]).append(",");
      }
      if (builder.length() > 0) {
        builder.setLength(builder.length() - 1);
        query.setOrdering(builder.toString());
      } else {
        query.setOrdering("partitionName ascending");
      }

      if (maxParts > -1) {
        query.setRange(0, maxParts);
      }

      String parameterDeclaration = makeParameterDeclarationStringObj(params);
      query.declareParameters(parameterDeclaration);
      Collection jdoRes = (Collection) query.executeWithMap(params);
      List<String> result = new LinkedList<String>();
      for (Object partName : jdoRes) {
        result.add((String) partName);
      }
      return result;
    }
  }
Drop an MPartition and cascade deletes (e.g., delete partition privilege grants,
  drop the storage descriptor cleanly, etc.)
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java