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 a Registry.

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 more SqlRegistry method implementations delegating to it. Its interface may change significantly at the same time. At present, this functionality has been factored out of SqlRegistry (with a bit of duplication) to allow the initial QueryBuilder 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; call fetchDatasetTypes 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 the dataset_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 that collections must be an ordered expression (regular expressions and are not allowed).

Returns:
subquery : sqlalchemy.sql.FromClause or None

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 of isResult and addRank. May be None if it is known that the query would return no results.