Record Class RelationFunctionSymbol

java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.function.RelationFunctionSymbol
Record Components:
namespace - the namespace this symbol belongs to; must not be blank
declaredName - the name as written by the user; must not be blank
provenance - built-in or user-defined; must not be null
shadowPolicy - replacement policy; must not be null
parameters - ordered parameter definitions; must not be null
body - the relational-algebra expression defining the result; must not be null
returnSchema - the body's inferred output schema; absent until inference resolves it
All Implemented Interfaces:
FunctionSymbol, Symbol

public record RelationFunctionSymbol(String namespace, String declaredName, Provenance provenance, ShadowPolicy shadowPolicy, List<ParameterDefinition> parameters, RelNode body, Optional<Schema> returnSchema) extends Record implements FunctionSymbol
A table-valued function symbol — a relation-returning user-defined function.

Where a ScalarFunctionSymbol accepts scalar arguments and yields a single scalar value, a RelationFunctionSymbol accepts scalar arguments and yields a whole relation: its body() is a relational-algebra RelNode expression, and its return "type" is a relation schema rather than a ScalarType. A table-valued function is declared with def name(p: T, …): RELATION := \{ <RA expression> \} — where a parameter may itself be a relation, E: RELATION(src, dst) — and invoked in relation position (as a RelationFunctionCall RelNode).

Binding is by substitution: a call's argument expressions replace the matching parameter references in the body, and the resulting relational expression is inlined by the planner. Because the binding is purely syntactic, this models a parameterized view.

The returnSchema() is the body's inferred output schema; it is empty until the schema-inference phase has resolved it (mirroring how a QueryRelationSymbol's schema is filled in after inference).

FunctionSymbol contract

A relation function carries no scalar return type; returnType() therefore reports ScalarType.ANY as a neutral placeholder (it is not meaningful for a relation function — consumers that distinguish the two function kinds should pattern-match on the concrete type). It declares no optimizer properties.

  • Constructor Details

  • Method Details

    • returnType

      public ScalarType returnType()
      The scalar return type, reported as ScalarType.ANY — a relation function does not return a scalar value (see returnSchema()).
      Specified by:
      returnType in interface FunctionSymbol
      Returns:
      ScalarType.ANY; never null
    • properties

      public Set<FunctionProperty> properties()
      Table-valued functions declare no optimizer hint flags.
      Specified by:
      properties in interface FunctionSymbol
      Returns:
      the empty set; never null
    • withReturnSchema

      public RelationFunctionSymbol withReturnSchema(Schema schema)
      Returns a copy of this symbol with its returnSchema() resolved to schema — used by the inference phase once the body's output schema has been derived.
      Parameters:
      schema - the resolved body schema; must not be null
      Returns:
      a new RelationFunctionSymbol carrying the resolved schema
    • builder

      public static RelationFunctionSymbol.Builder builder(String name)
      Returns a new RelationFunctionSymbol.Builder for a RelationFunctionSymbol with the given declared name.

      Builder defaults: namespace → "default", provenance → Provenance.USER, shadowPolicy → ShadowPolicy.PERMITTED, parameters → empty, returnSchema → Optional.empty().

      Parameters:
      name - the declared function name; must not be blank
      Returns:
      a fresh builder
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • namespace

      public String namespace()
      Returns the value of the namespace record component.
      Specified by:
      namespace in interface Symbol
      Returns:
      the value of the namespace record component
    • declaredName

      public String declaredName()
      Returns the value of the declaredName record component.
      Specified by:
      declaredName in interface Symbol
      Returns:
      the value of the declaredName record component
    • provenance

      public Provenance provenance()
      Returns the value of the provenance record component.
      Specified by:
      provenance in interface Symbol
      Returns:
      the value of the provenance record component
    • shadowPolicy

      public ShadowPolicy shadowPolicy()
      Returns the value of the shadowPolicy record component.
      Specified by:
      shadowPolicy in interface Symbol
      Returns:
      the value of the shadowPolicy record component
    • parameters

      public List<ParameterDefinition> parameters()
      Returns the value of the parameters record component.
      Specified by:
      parameters in interface FunctionSymbol
      Returns:
      the value of the parameters record component
    • body

      public RelNode body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • returnSchema

      public Optional<Schema> returnSchema()
      Returns the value of the returnSchema record component.
      Returns:
      the value of the returnSchema record component