Predicate¶
- final class lsst.daf.butler.queries.tree.Predicate(*, operands: tuple[tuple[typing.Annotated[lsst.daf.butler.queries.tree._predicate.IsNull | lsst.daf.butler.queries.tree._predicate.Comparison | lsst.daf.butler.queries.tree._predicate.InContainer | lsst.daf.butler.queries.tree._predicate.InRange | lsst.daf.butler.queries.tree._predicate.InQuery | lsst.daf.butler.queries.tree._predicate.BooleanWrapper | lsst.daf.butler.queries.tree._predicate.LogicalNot, FieldInfo(annotation=NoneType, required=True, discriminator='predicate_type')], ...], ...])¶
Bases:
QueryTreeBaseA boolean column expression.
Notes
Predicate is the only class representing a boolean column expression that should be used outside of this module (though the objects it nests appear in its serialized form and hence are not fully private). It provides several
classmethodfactories for constructing those nested types inside aPredicateinstance, andPredicateVisitorsubclasses should be used to process them.Attributes Summary
A string enumeration value representing the type of the column expression.
A dictionary of computed field names and their corresponding
ComputedFieldInfoobjects.Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].Metadata about the fields defined on the model, mapping of field names to [
FieldInfo][pydantic.fields.FieldInfo] objects.Methods Summary
compare(a, operator, b)Construct a predicate representing a binary comparison between two non-boolean column expressions.
from_bool(value)Construct a predicate that always evaluates to
TrueorFalse.from_bool_expression(value)Construct a predicate that wraps a boolean ColumnReference, taking on the value of the underlying ColumnReference.
gather_governors(governors)Add any governor dimensions that need to be fully identified for this column expression to be sound.
gather_required_columns(columns)Add any columns required to evaluate this predicate to the given column set.
in_container(member, container)Construct a predicate that tests whether one column expression is a member of a container of other column expressions.
in_query(member, column, query_tree)Construct a predicate that tests whether a column expression is present in a single-column projection of a query tree.
in_range(member[, start, stop, step])Construct a predicate that tests whether an integer column expression is part of a strided range.
is_null(operand)Construct a predicate that tests whether a column expression is NULL.
logical_and(*args)Construct a predicate representing the logical AND of this predicate and one or more others.
Construct a predicate representing the logical NOT of this predicate.
logical_or(*args)Construct a predicate representing the logical OR of this predicate and one or more others.
visit(visitor)Invoke the visitor interface.
Attributes Documentation
- column_type¶
A string enumeration value representing the type of the column expression.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding
ComputedFieldInfoobjects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'strict': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'operands': FieldInfo(annotation=tuple[tuple[Annotated[Union[IsNull, Comparison, InContainer, InRange, InQuery, BooleanWrapper, LogicalNot], FieldInfo(annotation=NoneType, required=True, discriminator='predicate_type')], ...], ...], required=True)}¶
Metadata about the fields defined on the model, mapping of field names to [
FieldInfo][pydantic.fields.FieldInfo] objects.This replaces
Model.__fields__from Pydantic V1.
Methods Documentation
- classmethod compare(a: IntColumnLiteral | StringColumnLiteral | FloatColumnLiteral | HashColumnLiteral | UUIDColumnLiteral | DateTimeColumnLiteral | TimespanColumnLiteral | RegionColumnLiteral | DimensionKeyReference | DimensionFieldReference | DatasetFieldReference | UnaryExpression | BinaryExpression, operator: Literal['==', '!=', '<', '>', '>=', '<=', 'overlaps'], b: IntColumnLiteral | StringColumnLiteral | FloatColumnLiteral | HashColumnLiteral | UUIDColumnLiteral | DateTimeColumnLiteral | TimespanColumnLiteral | RegionColumnLiteral | DimensionKeyReference | DimensionFieldReference | DatasetFieldReference | UnaryExpression | BinaryExpression) Predicate¶
Construct a predicate representing a binary comparison between two non-boolean column expressions.
- Parameters:
- a
ColumnExpression First column expression in the comparison.
- operator
str Enumerated string representing the comparison operator to apply. May be and of “==”, “!=”, “<”, “>”, “<=”, “>=”, or “overlaps”.
- b
ColumnExpression Second column expression in the comparison.
- a
- Returns:
- predicate
Predicate Predicate representing the comparison.
- predicate
- classmethod from_bool(value: bool) Predicate¶
Construct a predicate that always evaluates to
TrueorFalse.
- classmethod from_bool_expression(value: DimensionKeyReference | DimensionFieldReference | DatasetFieldReference) Predicate¶
Construct a predicate that wraps a boolean ColumnReference, taking on the value of the underlying ColumnReference.
- Parameters:
- value
ColumnExpression Boolean-valued expression to convert to Predicate.
- value
- Returns:
- predicate
Predicate Predicate representing the expression.
- predicate
- gather_governors(governors: set[str]) None¶
Add any governor dimensions that need to be fully identified for this column expression to be sound.
- gather_required_columns(columns: ColumnSet) None¶
Add any columns required to evaluate this predicate to the given column set.
- Parameters:
- columns
ColumnSet Set of columns to modify in place.
- columns
- classmethod in_container(member: IntColumnLiteral | StringColumnLiteral | FloatColumnLiteral | HashColumnLiteral | UUIDColumnLiteral | DateTimeColumnLiteral | TimespanColumnLiteral | RegionColumnLiteral | DimensionKeyReference | DimensionFieldReference | DatasetFieldReference | UnaryExpression | BinaryExpression, container: Iterable[IntColumnLiteral | StringColumnLiteral | FloatColumnLiteral | HashColumnLiteral | UUIDColumnLiteral | DateTimeColumnLiteral | TimespanColumnLiteral | RegionColumnLiteral | DimensionKeyReference | DimensionFieldReference | DatasetFieldReference | UnaryExpression | BinaryExpression]) Predicate¶
Construct a predicate that tests whether one column expression is a member of a container of other column expressions.
- classmethod in_query(member: ColumnExpression, column: ColumnExpression, query_tree: QueryTree) Predicate¶
Construct a predicate that tests whether a column expression is present in a single-column projection of a query tree.
- Parameters:
- member
ColumnExpression Column expression that may be present in the query.
- column
ColumnExpression Column to project from the query.
- query_tree
QueryTree Query tree to select from.
- member
- Returns:
- predicate
Predicate Predicate representing the membership test.
- predicate
- classmethod in_range(member: IntColumnLiteral | StringColumnLiteral | FloatColumnLiteral | HashColumnLiteral | UUIDColumnLiteral | DateTimeColumnLiteral | TimespanColumnLiteral | RegionColumnLiteral | DimensionKeyReference | DimensionFieldReference | DatasetFieldReference | UnaryExpression | BinaryExpression, start: int = 0, stop: int | None = None, step: int = 1) Predicate¶
Construct a predicate that tests whether an integer column expression is part of a strided range.
- Parameters:
- Returns:
- predicate
Predicate Predicate representing the membership test.
- predicate
- classmethod is_null(operand: IntColumnLiteral | StringColumnLiteral | FloatColumnLiteral | HashColumnLiteral | UUIDColumnLiteral | DateTimeColumnLiteral | TimespanColumnLiteral | RegionColumnLiteral | DimensionKeyReference | DimensionFieldReference | DatasetFieldReference | UnaryExpression | BinaryExpression) Predicate¶
Construct a predicate that tests whether a column expression is NULL.
- Parameters:
- operand
ColumnExpression Column expression to test.
- operand
- Returns:
- predicate
Predicate Predicate representing the NULL check.
- predicate
- logical_and(*args: Predicate) Predicate¶
Construct a predicate representing the logical AND of this predicate and one or more others.
- logical_not() Predicate¶
Construct a predicate representing the logical NOT of this predicate.
- Returns:
- predicate
Predicate Predicate representing the logical NOT.
- predicate