DatasetRegistryStorage¶
-
class
lsst.daf.butler.registry.queries.
DatasetRegistryStorage
(connection: sqlalchemy.engine.base.Connection, universe: lsst.daf.butler.core.dimensions.universe.DimensionUniverse, tables: Mapping[str, sqlalchemy.sql.selectable.FromClause], *, collections: lsst.daf.butler.registry.interfaces._collections.CollectionManager)¶ Bases:
object
An object managing
dataset
and related tables in aRegistry
.Parameters: - connection :
sqlalchemy.engine.Connection
A SQLAlchemy connection object, typically shared with the
Registry
that will own the storage instances.- universe :
DimensionUniverse
The set of all dimensions for which storage instances should be constructed.
- tables :
dict
A dictionary mapping table name to a
sqlalchemy.sql.FromClause
representing that table.
Notes
Future changes will convert this concrete class into a polymorphic hierarchy modeled after
DimensionRecordStorage
, with many moreSqlRegistry
method implementations delegating to it. Its interface may change significantly at the same time. At present, this functionality has been factored out ofSqlRegistry
(with a bit of duplication) to allow the initialQueryBuilder
design and implementation to be more forward-looking.Methods Summary
fetchDatasetTypes
(expression)Retrieve DatasetType
instances from the database matching an expression.getDatasetSubquery
(datasetType, *, …)Return a SQL expression that searches for a dataset of a particular type in one or more collections. Methods Documentation
-
fetchDatasetTypes
(expression: Any = Ellipsis) → Iterator[lsst.daf.butler.core.datasets.type.DatasetType]¶ Retrieve
DatasetType
instances from the database matching an expression.Parameters: - expression
An expression indicating the dataset type(s) to fetch. See DatasetType expressions for more information.
Yields: - datasetType
A dataset matching the given argument.
-
getDatasetSubquery
(datasetType: lsst.daf.butler.core.datasets.type.DatasetType, *, collections: Any, isResult: bool = True, addRank: bool = False) → Optional[sqlalchemy.sql.selectable.FromClause]¶ Return a SQL expression that searches for a dataset of a particular type in one or more collections.
Parameters: - datasetType :
DatasetType
Type of dataset to search for. Must be a true
DatasetType
; callfetchDatasetTypes
first to expand an expression if desired.- collections
An expression describing the collections to search and any restrictions on the dataset types to search within them. See Collection expressions for more information.
- isResult :
bool
, optional If
True
(default), include thedataset_id
column in the result columns of the query.- addRank :
bool
, optional If
True
(False
is default), also include a calculated column that ranks the collection in which the dataset was found (lower is better). Requires thatcollections
must be an ordered expression (regular expressions andare not allowed).
Returns: - subquery :
sqlalchemy.sql.FromClause
orNone
Named subquery or table that can be used in the FROM clause of a SELECT query. Has at least columns for all dimensions in
datasetType.dimensions
; may have additional columns depending on the values ofisResult
andaddRank
. May beNone
if it is known that the query would return no results.
- datasetType :
- connection :