Record Class Bind

java.lang.Object
java.lang.Record
io.trino.sql.ir.Bind
All Implemented Interfaces:
Expression

public record Bind(List<Expression> values, Lambda function) extends Record implements Expression
Bind(values, targetFunction)

When invoked, the returned function inserts the given values as the leading arguments to the targetFunction. The other arguments are passed unchanged.

Bind is fundamentally first class, just like function applications. It requires special treatment from the type system. There is no way to write out the type of `bind`. The return type of `bind` is function. Its type looks somewhat like:

  • X, (X) -> Y => () -> Y
  • X1, (X1, X2) -> Y => (X2) -> Y
  • X1, (X1, X2, X3) -> Y => (X2, X3) -> Y
  • X1, (X1, X2, X3, X4) -> Y => (X2, X3, X4) -> Y
  • ...

Lambda capturing is implemented through desugaring in Trino. This expression facilitates desugaring.