The weighted_sum UDAF takes a weight, type, and type-weight mapping to produce an aggregated weight. For example, consider the following SQL snippet:
    SELECT query,
          doc_id,
          filters,
          weighted_sum(typed_weight_d, type, 'click:1.0,cart:10.0') AS weight_d
     FROM signal_type_groups
 GROUP BY query, doc_id, filters
When applied to the rows in the table below, the weighted_sum function produces a final weight_d of 12.0 (21.0 + 110.0). The UDAF is passed rows grouped by query, doc_id, and filters.
querytypedoc_idfilterstyped_weight_d
iPadclick1gear2
iPadcart1gear1