Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-23899 Built-in SQL Function Improvement
  3. SPARK-23938

High-order function: map_zip_with(map<K, V1>, map<K, V2>, function<K, V1, V2, V3>) → map<K, V3>

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.3.0
    • 3.0.0
    • SQL
    • None

    Description

      Ref: https://prestodb.io/docs/current/functions/map.html

      Merges the two given maps into a single map by applying function to the pair of values with the same key. For keys only presented in one map, NULL will be passed as the value for the missing key.

      SELECT map_zip_with(MAP(ARRAY[1, 2, 3], ARRAY['a', 'b', 'c']), -- {1 -> ad, 2 -> be, 3 -> cf}
                          MAP(ARRAY[1, 2, 3], ARRAY['d', 'e', 'f']),
                          (k, v1, v2) -> concat(v1, v2));
      SELECT map_zip_with(MAP(ARRAY['k1', 'k2'], ARRAY[1, 2]), -- {k1 -> ROW(1, null), k2 -> ROW(2, 4), k3 -> ROW(null, 9)}
                          MAP(ARRAY['k2', 'k3'], ARRAY[4, 9]),
                          (k, v1, v2) -> (v1, v2));
      SELECT map_zip_with(MAP(ARRAY['a', 'b', 'c'], ARRAY[1, 8, 27]), -- {a -> a1, b -> b4, c -> c9}
                          MAP(ARRAY['a', 'b', 'c'], ARRAY[1, 2, 3]),
                          (k, v1, v2) -> k || CAST(v1/v2 AS VARCHAR));
      

      Attachments

        Activity

          People

            mn-mikke Marek Novotny
            smilegator Xiao Li
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: