Skip to content

Support a plan-level function definition in a plan #1220

Description

@yongchul

Motivation

  • Not only Rel's but Expression can be shared a "real" common subexpression. However, in Substrait model, sharing expression is not easy due to the field references, which relies on "offset" of binding schema rather than the "identity".

  • Another case is a real function defined in terms of substrait scalar expressions (i.e., UDF).

Proposal

Both scenario can be modeled a function and all the field references can be replaced as a function argument. On referenced site, we can substitute the common expression as a function invocation.

Depending on implementation, one can choose either make it true function call or inline the expression with the specific parameter bindings.

We can reuse the existing lambda infrastructure for definition and call site but the definition must reside in plan scope and in a separate namespace (i.e., separate anchor).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions