code: def _resolve_path_aggregation(
      path: str, view: foc.SampleCollection
  ) -> AggregateResult:
      aggregations: t.List[foa.Aggregation] = [
          foa.Count(path if path and path != "" else None)
      ]
      field = view.get_field(path)
  
      while isinstance(field, fof.ListField):
          field = field.field
  
      cls = (
          RESULT_MAPPING.get(field.__class__, DataAggregation)
          if path
          else RootAggregation
      )
  
      if meets_type(field, fof.BooleanField):
          aggregations.append(foa.CountValues(path))
  
      elif meets_type(
          field, (fof.DateField, fof.DateTimeField, fof.IntField)
      ):
          aggregations.append(foa.Bounds(path))
  
      elif meets_type(field, fof.FloatField):
          aggregations.append(
              foa.Bounds(
                  path,
                  safe=True,
                  _count_nonfinites=True,
              )
          )
  
      elif meets_type(field, (fof.ObjectIdField, fof.StringField)):
          aggregations.append(foa.CountValues(path, _first=LIST_LIMIT))
  
      data = {"path": path}
  
      def from_results(results):
          for aggregation, result in zip(aggregations, results):
              if isinstance(aggregation, foa.Bounds):
                  if isinstance(field, fof.FloatField):
                      mn, mx = result["bounds"]
                      data["inf"] = result["inf"]
                      data["min"] = mn
                      data["max"] = mx
                      data["nan"] = result["nan"]
                      data["ninf"] = result["-inf"]
                  else:
                      mn, mx = result
                      data["min"] = (
                          datetime_to_timestamp(mn)
                          if meets_type(mn, (datetime, date))
                          else mn
                      )
                      data["max"] = (
                          datetime_to_timestamp(mx)
                          if meets_type(mx, (datetime, date))
                          else mx
                      )
              elif isinstance(aggregation, foa.Count):
                  data["count"] = result
              elif isinstance(aggregation, foa.CountValues):
                  if isinstance(field, fof.BooleanField):
                      data["true"] = result.get(True, 0)
                      data["false"] = result.get(False, 0)
                  else:
                      _, result = result
                      data["values"] = [
                          {"value": value, "count": count}
                          for value, count in result
                      ]
              elif isinstance(aggregation, _CountExists):
                  data["exists"] = result
  
              if "exists" not in data:
                  data["exists"] = data["count"]
  
          if cls == RootAggregation:
              data["expanded_field_count"] = _count_expanded_fields(
                  view._root_dataset
              )
              if view._root_dataset.media_type == fom.VIDEO:
                  data["frame_label_field_count"] = len(
                      view._root_dataset.get_frame_field_schema(
                          embedded_doc_type=fol.Label
                      )
                  )
          return from_dict(cls, data)
  
      return aggregations, from_results
  
imports: from datetime import date, datetime
  import typing
  import strawberry
  import fiftyone.core.aggregations
  import fiftyone.core.collections
  import fiftyone.core.fields
  import fiftyone.core.labels
  import fiftyone.core.media
  from fiftyone.core.utils import datetime_to_timestamp
  import fiftyone.core.view
  from fiftyone.server.constants import LIST_LIMIT
  from fiftyone.server.filters import GroupElementFilter, SampleFilter
  from fiftyone.server.inputs import SelectedLabel
  from fiftyone.server.scalars import BSON, BSONArray
  from fiftyone.server.utils import from_dict, meets_type
  import fiftyone.server.view
label_desc: Use image node_id 1 for calling a global function with example usage: _resolve_path_aggregation(path, view) and returns: aggregations,  from_results, from_dict