Type.known_properties()#

relationalai
#Type.known_properties() -> list[str]

Returns a list of strings containing the names of all statically known properties of objects with the given Type.

Returns#

A list of str objects.

Example#

Use Type.known_properties() to get the names of properties known to be used by objects of the given type. Known properties are properties that can be statically inferred from a model’s rules. This includes properties imported from a Snowflake table, or set in a rule that directly references the Type.

In the following model, both the name and age properties are known to the Person type:

#import relationalai as rai


# =====
# SETUP
# =====

model = rai.Model("PeopleModel")

# Declare Person and Adult types.
Person = model.Type("Person")
Adult = model.Type("Adult")

# Define some Person objects.
with model.rule():
    Person.add(name="Alice", age=20)
    Person.add(name="Bob", age=15)

# Set the Adult type on Person objects whose age property is at least 18.
with model.rule():
    person = Person()
    person.age >= 18
    person.set(Adult)


# =======
# EXAMPLE
# =======

print(Person.known_properties())
# ['name', 'age']

However, the Adult type does not know about the name or age properties since they inherit those properties indirectly from the Person type:

#print(Adult.known_properties())
# []

See Also#