def merge_parameters(parameters, date_time, macros, types_and_values):
    """ Merge Return a mapping from airflow macro names (prefixed with '_') to values

    Args:
      date_time: The timestamp at which the macro values need to be evaluated. This is only
          applicable when types_and_values = True
      macros: If true, the values in the returned dict are the macro strings (like '{{ ds }}')

    Returns:
      The resolved value, i.e. the value with the format modifiers replaced with the corresponding
          parameter-values. E.g. if value is <project-id>.<dataset-id>.logs_%(_ds)s, the returned
          value could be <project-id>.<dataset-id>.logs_2017-12-21.
    """
    merged_parameters = Query._airflow_macro_formats(date_time=date_time, macros=macros,
                                                     types_and_values=types_and_values)
    if parameters:
      if types_and_values:
        parameters = {
          item['name']: {'value': item['value'], 'type': item['type']}
          for item in parameters
        }
      else:  # macros = True, or the default (i.e. just values)
        parameters = {item['name']: item['value'] for item in parameters}

      merged_parameters.update(parameters)
    return merged_parameters