Skip to content

Match

relationalai.semantics.frontend.base
Match(model: Model, *items: Statement)

Represents a left-to-right fallback across alternative branches.

Match is the object created by the | operator for semantics DSL values and statements (see Variable.__or__). At execution time, it evaluates branches left-to-right and picks the first branch that can succeed for the current bindings.

Each branch must return the same number of values; the result behaves like a derived table with that many columns.

Nested matches are flattened, so (a | b) | c is equivalent to a | b | c.

  • model

    (Model) - The model this match belongs to.
  • *items

    (Statement, default: ()) - Branches to try in order. Each branch must return the same number of values.

Most users should not instantiate this class directly. Use a | b for fallback/default behavior, or Model.union to combine results from multiple branches.

Match.__getattr__(item) -> Chain

Follow a relationship/property from the last returned value.

This forwards attribute access to the last output column of the match, so you can write expressions like union(Cat, Dog).name or (a | b).name when the branches return an entity-like value.

Names that start with an underscore are treated as normal Python attribute access.

Parameters:

  • item

    (str) - Relationship/property name to access.

Returns:

  • Chain - A chained value rooted at the last output column.
MatchDerivedTableVariableDSLBase
 semantics > frontend > base
├──  Fragment
│   └──  __or__
├──  Not
│   └──  __or__
└──  Variable
    └──  __or__