code: def get_aggregations(metrics_dict, saved_metrics, adhoc_metrics=[]):
          
          aggregations = OrderedDict()
          invalid_metric_names = []
          for metric_name in saved_metrics:
              if metric_name in metrics_dict:
                  metric = metrics_dict[metric_name]
                  if metric.metric_type == POST_AGG_TYPE:
                      invalid_metric_names.append(metric_name)
                  else:
                      aggregations[metric_name] = metric.json_obj
              else:
                  invalid_metric_names.append(metric_name)
          if len(invalid_metric_names) > 0:
              raise SupersetException(
                  _('Metric(s) {} must be aggregations.').format(invalid_metric_names))
          for adhoc_metric in adhoc_metrics:
              aggregations[adhoc_metric['label']] = {
                  'fieldName': adhoc_metric['column']['column_name'],
                  'fieldNames': [adhoc_metric['column']['column_name']],
                  'type': DruidDatasource.druid_type_from_adhoc_metric(adhoc_metric),
                  'name': adhoc_metric['label'],
              }
          return aggregations
docs: Returns a dictionary of aggregation metric names to aggregation json objects
  
              :param metrics_dict: dictionary of all the metrics
              :param saved_metrics: list of saved metric names
              :param adhoc_metrics: list of adhoc metric names
              :raise SupersetException: if one or more metric names are not aggregations