Skip to content

type variables in scalar function signatures #452

@benbellick

Description

@benbellick

Function signatures in Substrait extensions can use type variables for polymorphism. Examples from the core extensions:

  • any1, any2 - match any type (e.g., first_value(any1) -> any1)
  • any1? - nullable type variable
  • decimal<P1,S1> - decimal with parameter variables for precision/scale
  • varchar<L1> - varchar with length parameter variable

Currently, when parsing a return type or argument type that contains these variables, ConcreteType::try_from(TypeExpr) fails with errors like InvalidAnyTypeVariable, and the function is skipped with a NotYetImplemented error.

https://github.com/substrait-io/substrait-rs/blob/main/src/parse/text/simple_extensions/scalar_functions.rs#L148-L156

Supporting this would require either an owned version of TypeExpr (which currently borrows from the source string) or a new type that can represent both concrete types and type expressions with variables. Properly using these for type checking and function resolution would be additional work beyond just parsing.

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