Skip to content

FieldRef

relationalai.semantics.frontend.base
FieldRef(root: Chain | Relationship | Expression, field: str | int | Concept)

Refer to a specific field of a relationship.

FieldRef objects are created by indexing a Relationship, Chain, or Expression (for example, Person.pets["pet_name"]). They are commonly used to select, join, or filter on non-output fields of a relationship.

  • root

    (Chain | Relationship | Expression) - The relationship-like object being indexed.
  • field

    (str | int | Concept) - The selector used to identify the field (name, 0-based index, or field concept type).

Most users should not construct FieldRef objects directly. Prefer indexing helpers such as Relationship.__getitem__, Chain.__getitem__, and Expression.__getitem__.

FieldRef.__getattr__(item)

Return a chained relationship reference for attribute access.

A FieldRef behaves like a variable of its field’s Concept type. Accessing Person.works_for["company"].name returns a Chain rooted at this field reference.

If the attribute name starts with an underscore, this method defers to normal Python attribute access so internal attributes remain accessible.

Parameters:

  • item

    (str) - Relationship/property name to access on the field’s concept type.

Returns:

  • Chain - A chained value representing the relationship reading.

Raises:

  • relationalai.util.error.RAIException - Raised in the following cases:
    • The field’s concept type does not declare the relationship and implicit properties are disabled (model.implicit_properties config flag).
    • Relationships are accessed on a core concept, like CoreConcepts.String or CoreConcepts.Integer.
FieldRefVariableDSLBase
 semantics > frontend > base
├──  Chain
│   └──  __getitem__
├──  Expression
│   └──  __getitem__
└──  Relationship
    └──  __getitem__
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works > Build a semantic model
        └──  Query a model
            └──  Select values with select