Skip to content

Add onEach scalar function #1138

@norberttech

Description

@norberttech

As explained on Discrod we are missing a function that could apply other function on each element of intput array.

Example:

Input List

[
  ["action_type" => "action_1", "value" => 12.123],
  ["action_type" => "action_2", "value" => 10]
]

Function:

ref('cost_per_action_type')->eachElement(ref("value")->cast(type_float())

Inside eval method of OnEach function we would need to get value of provided ref (list/map/struct/array), then iterate through it and convert each element to row, then execute provided scalar function on it and then convert it back to with Row::toArray().
When provided ref does not points to array like structure, it should return null.

Apache spark also provides similar function, however they called it transform:

Image

https://spark.apache.org/docs/latest/api/scala/org/apache/spark/sql/functions$.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions