TimespanDatabaseRepresentation¶
-
class
lsst.daf.butler.TimespanDatabaseRepresentation¶ Bases:
lsst.daf.butler.TopologicalExtentDatabaseRepresentationAn interface that encapsulates how timespans are represented in a database engine.
Most of this class’s interface is comprised of classmethods. Instances can be constructed via the
fromSelectablemethod as a way to include timespan overlap operations in query JOIN or WHERE clauses.Attributes Summary
NAMEBase name for all timespan fields in the database ( str).Methods Summary
extract(mapping, Any])Extract a Timespaninstance from a dictionary that represents a database row in this representation.fromSelectable(selectable)Construct an instance that represents a logical column (which may actually be backed by multiple columns) in the given table or subquery. getFieldNames()Return the actual field names used by this representation. hasExclusionConstraint()Return Trueif this representation supports exclusion constraints.isNull()Return a SQLAlchemy expression that tests whether this timespan is logically NULL.makeFieldSpecs(nullable, **kwargs)Make one or more ddl.FieldSpecobjects that reflect the fields that must be added to a table for this representation.overlaps(other, _S])Return a SQLAlchemy expression representing an overlap operation on timespans. update(timespan, *, result, Any]] = None)Add a Timespanto a dictionary that represents a database row in this representation.Attributes Documentation
-
NAME= 'timespan'¶ Base name for all timespan fields in the database (
str).Actual field names may be derived from this, rather than exactly this.
Methods Documentation
-
classmethod
extract(mapping: Mapping[str, Any]) → Optional[lsst.daf.butler.core.timespan.Timespan]¶ Extract a
Timespaninstance from a dictionary that represents a database row in this representation.Parameters: - mapping :
Mapping[str,Any] A dictionary representing a database row containing a
Timespanin this representation. Should have key(s) equal to the return value ofgetFieldNames.
Returns: - mapping :
-
classmethod
fromSelectable(selectable: sqlalchemy.sql.selectable.FromClause) → _S¶ Construct an instance that represents a logical column (which may actually be backed by multiple columns) in the given table or subquery.
Parameters: - selectable :
sqlalchemy.sql.FromClause SQLAlchemy object representing a table or subquery.
Returns: - representation :
TopologicalExtentDatabaseRepresentation Object representing a logical column.
- selectable :
-
classmethod
getFieldNames() → Tuple[str, ...]¶ Return the actual field names used by this representation.
Returns: - names :
tuple[str] Field name(s). Guaranteed to be the same as the names of the field specifications returned by
makeFieldSpecs.
- names :
-
classmethod
hasExclusionConstraint() → bool¶ Return
Trueif this representation supports exclusion constraints.Returns:
-
isNull() → sqlalchemy.sql.elements.ColumnElement¶ Return a SQLAlchemy expression that tests whether this timespan is logically
NULL.Returns: - isnull :
sqlalchemy.sql.ColumnElement A boolean SQLAlchemy expression object.
- isnull :
-
classmethod
makeFieldSpecs(nullable: bool, **kwargs) → Tuple[lsst.daf.butler.core.ddl.FieldSpec, ...]¶ Make one or more
ddl.FieldSpecobjects that reflect the fields that must be added to a table for this representation.Parameters: - nullable :
bool If
True, the timespan is permitted to be logicallyNULL(mapped toNonein Python), though the correspoding value(s) in the database are implementation-defined. Nullable timespan fields default to NULL, while others default to (-∞, ∞).- **kwargs
Keyword arguments are forwarded to the
ddl.FieldSpecconstructor for all fields; implementations only provide thename,dtype, anddefaultarguments themselves.
Returns: - specs :
tuple[ddl.FieldSpec] Field specification objects; length of the tuple is subclass-dependent, but is guaranteed to match the length of the return values of
getFieldNamesandupdate.
- nullable :
-
overlaps(other: Union[lsst.daf.butler.core.timespan.Timespan, _S]) → sqlalchemy.sql.elements.ColumnElement¶ Return a SQLAlchemy expression representing an overlap operation on timespans.
Parameters: - other :
TimespanorTimespanDatabaseRepresentation The timespan to overlap
selfwith; either a PythonTimespanliteral or an instance of the sameTimespanDatabaseRepresentationasself, representing a timespan in some other table or query within the same database.
Returns: - overlap :
sqlalchemy.sql.ColumnElement A boolean SQLAlchemy expression object.
- other :
-