ColumnExpression¶
- class lsst.daf.relation.ColumnExpression¶
Bases:
ABCAn abstract base class and factory for scalar, non-boolean column expressions.
ColumnExpressioninheritance is closed to the types already provided by this package, but considerable custom behavior can still be provided via theColumnFunctionclass and anEnginethat knows how to interpret itsnamevalue. These concrete types can all be constructed via factory methods onColumnExpressionitself, so the derived types themselves only need to be referenced when writingmatchexpressions that process an expression tree. See Extensibility for rationale and details.Attributes Summary
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])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])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: ColumnExpression) PredicateFunction¶
Construct a boolean equality-comparison expression.
- Parameters:
- other
ColumnExpression Expression whose value will be compared to that of
self.
- other
- Returns:
- comparison
Predicate Boolean column expression.
- comparison
- classmethod function(name: str, *args: ColumnExpression, 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
Engineor 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
typeorNone, optional The Python type this expression evaluates to (
typeorNone).- supporting_engine_types
Iterable[type], optional If provided, the set of
Enginetypes that are expected to support this expression. IfNone(default), all engines are assumed to support it.
- name
- Returns:
- function
ColumnFunction Column expression that represents this function call.
- function
- ge(other: ColumnExpression) PredicateFunction¶
Construct a boolean greater-or-equal-comparison expression.
- Parameters:
- other
ColumnExpression Expression whose value will be compared to that of
self.
- other
- Returns:
- comparison
Predicate Boolean column expression.
- comparison
- gt(other: ColumnExpression) PredicateFunction¶
Construct a boolean greater-than-comparison expression.
- Parameters:
- other
ColumnExpression Expression whose value will be compared to that of
self.
- other
- Returns:
- comparison
Predicate Boolean column expression.
- comparison
- abstract is_supported_by(engine: Engine) bool¶
Test whether the given engine is capable of evaluating this expression.
- le(other: ColumnExpression) PredicateFunction¶
Construct a boolean less-or-equal-comparison expression.
- Parameters:
- other
ColumnExpression Expression whose value will be compared to that of
self.
- other
- Returns:
- comparison
Predicate Boolean column expression.
- comparison
- classmethod literal(value: Any, dtype: type | None = None) 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: ColumnExpression) PredicateFunction¶
Construct a boolean less-than-comparison expression.
- Parameters:
- other
ColumnExpression Expression whose value will be compared to that of
self.
- other
- Returns:
- comparison
Predicate Boolean column expression.
- comparison
- method(name: str, *args: ColumnExpression, 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
Engineor other algorithm.- *args
ColumnExpression Expressions to pass as arguments to the method (after
self).- dtype
typeorNone, optional The Python type this expression evaluates to (
typeorNone).- supporting_engine_types
Iterable[type], optional If provided, the set of
Enginetypes that are expected to support this expression. IfNone(default), all engines are assumed to support it.
- name
- Returns:
- function
ColumnFunction Column expression that represents this function call.
- function
Notes
ColumnExpressioncannot 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
iterationandsqlengines both interpret these names as method names if and only if they are not first found in the built-inoperatormodule.
- ne(other: ColumnExpression) PredicateFunction¶
Construct a boolean inequality-comparison expression.
- Parameters:
- other
ColumnExpression Expression whose value will be compared to that of
self.
- other
- Returns:
- comparison
Predicate Boolean column expression.
- comparison
- classmethod predicate_function(name: str, *args: ColumnExpression, 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
Engineor 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
typeorNone, optional The Python type this expression evaluates to (
typeorNone).- supporting_engine_types
Iterable[type], optional If provided, the set of
Enginetypes that are expected to support this expression. IfNone(default), all engines are assumed to support it.
- name
- Returns:
- function
PredicateFunction Boolean column expression that represents this function call.
- function
- predicate_method(name: str, *args: ColumnExpression, 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
Engineor other algorithm.- *args
ColumnExpression Expressions to pass as arguments to the method (after
self).- dtype
typeorNone, optional The Python type this expression evaluates to (
typeorNone).- supporting_engine_types
Iterable[type] optional If provided, the set of
Enginetypes that are expected to support this expression. IfNone(default), all engines are assumed to support it.
- name
- Returns:
- function
PredicateFunction Boolean column expression that represents this function call.
- function
Notes
ColumnExpressioncannot 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
iterationandsqlengines both interpret these names as method names if and only if they are not first found in the built-inoperatormodule.
- classmethod reference(tag: ColumnTag, dtype: type | None = None) ColumnReference¶
Construct an expression that refers to a column in a relation.