select
relationalai.semantics
select(*args: StatementAndSchema) -> FragmentReturn a selection fragment from the active model.
This is a convenience wrapper around Model.select that operates on the single active model.
It returns a composable Fragment that can be further refined with
Fragment.where, Fragment.define,
and Fragment.require, and materialized via Fragment.to_df.
If you have more than one model, call Model.select on the specific model instead.
Parameters
Section titled “Parameters”-
(*argsStatementAndSchema, default:()) - Items to select. You can pass either:- A
semantics.frontend.base.Statement(e.g., a property/relationship, expression, or literal) - A
TableSchema(typically created viaTable.to_schema), which is expanded into selecting each column of the table.
- A
Returns
Section titled “Returns”Fragment- A composable query fragment representing the selection.
Raises
Section titled “Raises”relationalai.util.error.RAIException- If there is no active model, or if multiple models exist and the active model would be ambiguous.
Examples
Section titled “Examples”Select a literal value and materialize the result as a pandas DataFrame:
>>> from relationalai.semantics import Model, select, where>>> m = Model()>>> select(1).to_df()Combine with filters:
>>> Person = m.Concept("Person")>>> define(... Person.new(name="Alice", age=10),... Person.new(name="Bob", age=30),... )>>> select(Person.name, Person.age).where(Person.age > 21).to_df()Extract the selected values by unpacking the fragment:
>>> name, age = select(Person.name, Person.age)>>> where(age >= 18).select(name).to_df()Referenced By
Section titled “Referenced By”RelationalAI Documentation └── Release Notes └── Python API Release Notes └── What’s New in Version 1.0.0 └── Breaking Changes