code: private static Constraints constraints(FileSystemPartitionView<?> view,
                                           @Nullable URI relative) {
      DatasetDescriptor descriptor = view.dataset.getDescriptor();
  
      if (relative == null) {
        // no partitions are selected, so no additional constraints
        return view.constraints;
      }
  
      Preconditions.checkArgument(descriptor.isPartitioned(),
          "Dataset is not partitioned");
  
      Constraints constraints = view.constraints;
  
      Schema schema = descriptor.getSchema();
      PartitionStrategy strategy = descriptor.getPartitionStrategy();
  
      PathConversion conversion = new PathConversion(schema);
      Iterator<String> parts = PATH_SPLITTER.split(relative.getRawPath()).iterator();
      for (FieldPartitioner<?, ?> fp : Accessor.getDefault().getFieldPartitioners(strategy)) {
        if (!parts.hasNext()) {
          break;
        }
        constraints = constraints.with(
            fp.getName(), conversion.valueForDirname(fp, parts.next()));
      }
  
      Preconditions.checkArgument(!parts.hasNext(),
          "%s is deeper than the partition strategy", relative);
  
      return constraints;
    }
docs: Build partition constraints for the partition URI location.
  
  @param view a {@code FileSystemPartitionView} containing {@code location}
  @param relative a relative URI for a partition within the given view
  @return a set of constraints that match the location