Not
Not(*items: Statement, model: Model)Represents a negated condition for use in query filters.
Not is the object created by Model.not_ (and the convenience function
not_). Use it inside Model.where to exclude
bindings that match a pattern; multiple items are treated as a single
grouped condition (NOT (a AND b)).
Parameters
Section titled “Parameters”Most users should not instantiate this class directly. Prefer
Model.not_.
Methods
Section titled “Methods”.__or__()
Section titled “.__or__()”Not.__or__(other) -> MatchReturn a match expression (self | other).
a | b builds a Match
with two branches. At execution time, the match picks the first branch
(left-to-right) that can succeed for the current bindings.
Parameters:
(otherStatement) - The right-hand branch.
Returns:
Match- A composable match expression.
.__and__()
Section titled “.__and__()”Not.__and__(other) -> FragmentReturn a fragment that combines conditions with AND (self & other).
Use & to explicitly conjoin conditions when building filters. This is
equivalent to passing multiple conditions to Model.where.
If other is a Fragment, this returns a new fragment with self
added to other’s filters (roughly other.where(self)).
Parameters:
(otherStatement or Fragment) - The right-hand operand. This is typically a condition expression, but it may also be an existing fragment to extend.
Returns:
Fragment- A composable fragment representing the conjunction.
Raises:
relationalai.util.error.RAIException- Ifotheris not a valid statement in a filter.NotImplementedError- If a Python value cannot be converted to a supported literal.
Examples:
Extend an existing fragment by adding another condition, then continue chaining:
>>> from relationalai.semantics import Model>>> m = Model()>>> User = m.Concept("User")>>> m.define(... User.new(username="alice", age=30, status="active"),... User.new(username="bob", age=15, status="inactive"),... User.new(username="carol", age=40, status="active"),... )>>> active_users = m.where(User.status == "active")>>> active_adults = active_users & m.not_(User.age < 18)>>> active_adults.select(User.username).to_df()Notes:
Do not use Python’s boolean and with DSL values. Use &
(or pass multiple conditions to where) instead.
Inheritance Hierarchy
Section titled “Inheritance Hierarchy”Used By
Section titled “Used By”semantics > frontend > base └── Statement