Type#

relationalai
#class Type

Types are used to categorize objects in a model. You declare types using the Model.Type() method, which returns an instance of the Type class.

Methods#

NameDescriptionReturns
.__and__()Supports the & operator for defining intersections of types.TypeIntersection
.__call__()Gets a reference to objects with the given type.Instance
.__or__()Supports the | operator for defining unions of types.TypeUnion
.add()Adds a new object with the given type.Instance
.define()Defines properties for a type based on foreign key relationships to other types.None
.extend()Extends the type with all objects from another type.None
.known_properties()Gets all statically known properties of objects with the given type.list[str]

Example#

Use Model.Type() to create a Type object rather than constructing one directly:

#import relationalai as rai

model = rai.Model("MyModel")

# Declare Person and Adult types using the model.Type() method. The optional
# source parameter specifies a Snowflake table with source data for objects with
# the given type.
Person = model.Type("Person", source="<db>.<schema>.<table>")
Adult = model.Type("Adult")

See Model.Type() for more information.

See Also#