ColumnExpression¶
-
class
lsst.daf.relation.
ColumnExpression
¶ Bases:
abc.ABC
An abstract base class and factory for scalar, non-boolean column expressions.
ColumnExpression
inheritance is closed to the types already provided by this package, but considerable custom behavior can still be provided via theColumnFunction
class and anEngine
that knows how to interpret itsname
value. These concrete types can all be constructed via factory methods onColumnExpression
itself, so the derived types themselves only need to be referenced when writingmatch
expressions that process an expression tree. See Extensibility for rationale and details.Attributes Summary
columns_required
Columns required by this expression ( Set
[ColumnTag
]).Methods Summary
eq
(other)Construct a boolean equality-comparison expression. function
(name, *args, dtype, …)Construct an expression that represents a function call with expression arguments. ge
(other)Construct a boolean greater-or-equal-comparison expression. gt
(other)Construct a boolean greater-than-comparison expression. is_supported_by
(engine)Test whether the given engine is capable of evaluating this expression. le
(other)Construct a boolean less-or-equal-comparison expression. literal
(value, dtype, None] = None)Construct an expression backed by a regular Python object. lt
(other)Construct a boolean less-than-comparison expression. method
(name, *args, dtype, …)Construct an expression that represents a method call with expression arguments. ne
(other)Construct a boolean inequality-comparison expression. predicate_function
(name, *args, …)Construct an expression that represents a function call with expression arguments and a boolean result. predicate_method
(name, *args, …)Construct an expression that represents a method call with expression arguments and a boolean result. reference
(tag, dtype, None] = None)Construct an expression that refers to a column in a relation. Attributes Documentation
-
columns_required
¶ Columns required by this expression (
Set
[ColumnTag
]).This includes columns required by expressions nested within this one.
Methods Documentation
-
eq
(other: lsst.daf.relation._columns._expression.ColumnExpression) → lsst.daf.relation._columns._expression.PredicateFunction¶ Construct a boolean equality-comparison expression.
Parameters: - other :
ColumnExpression
Expression whose value will be compared to that of
self
.
Returns: - comparison :
Predicate
Boolean column expression.
- other :
-
classmethod
function
(name: str, *args, dtype: type | None = None, supporting_engine_types: Iterable[type[Engine]] | None = None) → ColumnFunction¶ Construct an expression that represents a function call with expression arguments.
Parameters: - name :
str
Name of the method, to be interpreted by the
Engine
or other algorithm.- *args :
ColumnExpression
Expressions to pass as arguments to the method (not including
self
; this is aclassmethod
, so it never has access toself
).- dtype :
type
orNone
, optional The Python type this expression evaluates to (
type
orNone
).- supporting_engine_types :
Iterable
[type
], optional If provided, the set of
Engine
types that are expected to support this expression. IfNone
(default), all engines are assumed to support it.
Returns: - function :
ColumnFunction
Column expression that represents this function call.
- name :
-
ge
(other: lsst.daf.relation._columns._expression.ColumnExpression) → lsst.daf.relation._columns._expression.PredicateFunction¶ Construct a boolean greater-or-equal-comparison expression.
Parameters: - other :
ColumnExpression
Expression whose value will be compared to that of
self
.
Returns: - comparison :
Predicate
Boolean column expression.
- other :
-
gt
(other: lsst.daf.relation._columns._expression.ColumnExpression) → lsst.daf.relation._columns._expression.PredicateFunction¶ Construct a boolean greater-than-comparison expression.
Parameters: - other :
ColumnExpression
Expression whose value will be compared to that of
self
.
Returns: - comparison :
Predicate
Boolean column expression.
- other :
-
is_supported_by
(engine: Engine) → bool¶ Test whether the given engine is capable of evaluating this expression.
Parameters: - engine :
Engine
Engine to test.
Returns: - supported :
bool
Whether the engine supports this expression and all expressions nested within it.
- engine :
-
le
(other: lsst.daf.relation._columns._expression.ColumnExpression) → lsst.daf.relation._columns._expression.PredicateFunction¶ Construct a boolean less-or-equal-comparison expression.
Parameters: - other :
ColumnExpression
Expression whose value will be compared to that of
self
.
Returns: - comparison :
Predicate
Boolean column expression.
- other :
-
classmethod
literal
(value: Any, dtype: Optional[type, None] = None) → lsst.daf.relation._columns._expression.ColumnLiteral¶ Construct an expression backed by a regular Python object.
Parameters: Returns: - literal :
ColumnLiteral
A column expression backed by the given value.
- literal :
-
lt
(other: lsst.daf.relation._columns._expression.ColumnExpression) → lsst.daf.relation._columns._expression.PredicateFunction¶ Construct a boolean less-than-comparison expression.
Parameters: - other :
ColumnExpression
Expression whose value will be compared to that of
self
.
Returns: - comparison :
Predicate
Boolean column expression.
- other :
-
method
(name: str, *args, dtype: type | None = None, supporting_engine_types: Iterable[type[Engine]] | None = None) → ColumnFunction¶ Construct an expression that represents a method call with expression arguments.
Parameters: - name :
str
Name of the method, to be interpreted by the
Engine
or other algorithm.- *args :
ColumnExpression
Expressions to pass as arguments to the method (after
self
).- dtype :
type
orNone
, optional The Python type this expression evaluates to (
type
orNone
).- supporting_engine_types :
Iterable
[type
], optional If provided, the set of
Engine
types that are expected to support this expression. IfNone
(default), all engines are assumed to support it.
Returns: - function :
ColumnFunction
Column expression that represents this function call.
Notes
ColumnExpression
cannot actually force an engine to interpret the given name as the name of a method rather than something else; calling this method like this:a.method("name", b)
is exactly equivalent to:
ColumnExpression.function("name", a, b)
The provided
iteration
andsql
engines both interpret these names as method names if and only if they are not first found in the built-inoperator
module.- name :
-
ne
(other: lsst.daf.relation._columns._expression.ColumnExpression) → lsst.daf.relation._columns._expression.PredicateFunction¶ Construct a boolean inequality-comparison expression.
Parameters: - other :
ColumnExpression
Expression whose value will be compared to that of
self
.
Returns: - comparison :
Predicate
Boolean column expression.
- other :
-
classmethod
predicate_function
(name: str, *args, supporting_engine_types: Iterable[type[Engine]] | None = None) → PredicateFunction¶ Construct an expression that represents a function call with expression arguments and a boolean result.
Parameters: - name :
str
Name of the method, to be interpreted by the
Engine
or other algorithm.- *args :
ColumnExpression
Expressions to pass as arguments to the method (not including
self
; this is aclassmethod
, so it never has access toself
).- dtype :
type
orNone
, optional The Python type this expression evaluates to (
type
orNone
).- supporting_engine_types :
Iterable
[type
], optional If provided, the set of
Engine
types that are expected to support this expression. IfNone
(default), all engines are assumed to support it.
Returns: - function :
PredicateFunction
Boolean column expression that represents this function call.
- name :
-
predicate_method
(name: str, *args, supporting_engine_types: Set[type[Engine]] | None = None) → PredicateFunction¶ Construct an expression that represents a method call with expression arguments and a boolean result.
Parameters: - name :
str
Name of the method, to be interpreted by the
Engine
or other algorithm.- *args :
ColumnExpression
Expressions to pass as arguments to the method (after
self
).- dtype :
type
orNone
, optional The Python type this expression evaluates to (
type
orNone
).- supporting_engine_types :
Iterable
[type
] optional If provided, the set of
Engine
types that are expected to support this expression. IfNone
(default), all engines are assumed to support it.
Returns: - function :
PredicateFunction
Boolean column expression that represents this function call.
Notes
ColumnExpression
cannot actually force an engine to interpret the given name as the name of a method rather than something else; calling this method like this:a.predicate_method("name", b)
is exactly equivalent to:
ColumnExpression.predicate_function("name", a, b)
The provided
iteration
andsql
engines both interpret these names as method names if and only if they are not first found in the built-inoperator
module.- name :
-
classmethod
reference
(tag: lsst.daf.relation._columns._tag.ColumnTag, dtype: Optional[type, None] = None) → lsst.daf.relation._columns._expression.ColumnReference¶ Construct an expression that refers to a column in a relation.
Parameters: Returns: - reference :
ColumnReference
A column expression that refers the given relation column.
- reference :
-