bsfs.query.ast.filter_ module#
Filter AST.
Note that it is easily possible to construct an AST that is inconsistent with a given schema. Furthermore, it is possible to construct a semantically invalid AST which that cannot be parsed correctly or includes contradicting statements. The AST nodes do not (and cannot) check such issues.
For example, consider the following AST:
>>> Any(ns.bse.collection,
... And(
... Equals('hello'),
... Is('hello world'),
... Any(ns.bse.tag, Equals('world')),
... Any(ns.bst.label, Equals('world')),
... All(ns.bst.label, Not(Equals('world'))),
... )
... )
This AST has multiple issues that are not verified upon its creation: * A condition on a non-literal. * A Filter on a literal. * Conditions exclude each other * The predicate along the branch have incompatible domains and ranges.
- class bsfs.query.ast.filter_.All(predicate: PredicateExpression | URI, expr: FilterExpression)#
Bases:
_BranchAll (and at least one) triples match.
- class bsfs.query.ast.filter_.And(*expr: FilterExpression | Iterable[FilterExpression] | Iterator[FilterExpression])#
Bases:
_AggAll conditions match.
- class bsfs.query.ast.filter_.Any(predicate: PredicateExpression | URI, expr: FilterExpression)#
Bases:
_BranchAny (and at least one) triple matches.
- class bsfs.query.ast.filter_.EndsWith(value: Any)#
Bases:
_ValueValue ends with a given string.
- class bsfs.query.ast.filter_.Equals(value: Any)#
Bases:
_ValueValue matches exactly. NOTE: Value must correspond to literal type.
- class bsfs.query.ast.filter_.FilterExpression#
Bases:
_ExpressionGeneric Filter expression.
- class bsfs.query.ast.filter_.GreaterThan(threshold: float, strict: bool = True)#
Bases:
_BoundedValue is (strictly) larger than threshold. Assumes a Number literal.
- class bsfs.query.ast.filter_.Has(predicate: PredicateExpression | URI, count: FilterExpression | int | None = None)#
Bases:
FilterExpressionHas predicate N times
- count: FilterExpression#
- predicate: PredicateExpression#
- class bsfs.query.ast.filter_.Is(value: Any)#
Bases:
_ValueMatch the URI of a node.
- class bsfs.query.ast.filter_.LessThan(threshold: float, strict: bool = True)#
Bases:
_BoundedValue is (strictly) smaller than threshold. Assumes a Number literal.
- class bsfs.query.ast.filter_.Not(expr: FilterExpression)#
Bases:
FilterExpressionInvert a statement.
- expr: FilterExpression#
- class bsfs.query.ast.filter_.OneOf(*expr: PredicateExpression | URI)#
Bases:
PredicateExpression,CollectionA set of predicate alternatives.
The predicates’ domains must be ascendants or descendants of each other. The overall domain is the most specific one.
The predicate’s domains must be ascendants or descendants of each other. The overall range is the most generic one.
- expr: Set[PredicateExpression]#
- class bsfs.query.ast.filter_.Or(*expr: FilterExpression | Iterable[FilterExpression] | Iterator[FilterExpression])#
Bases:
_AggAt least one condition matches.
- class bsfs.query.ast.filter_.Predicate(predicate: URI, reverse: bool | None = False)#
Bases:
PredicateExpressionA single predicate.
- reverse: bool#
- class bsfs.query.ast.filter_.PredicateExpression#
Bases:
_ExpressionGeneric Predicate expression.
- class bsfs.query.ast.filter_.StartsWith(value: Any)#
Bases:
_ValueValue begins with a given string.
- class bsfs.query.ast.filter_.Substring(value: Any)#
Bases:
_ValueValue matches a substring NOTE: value must be a string.