ParentDatasetQueryResults¶
-
class
lsst.daf.butler.registry.queries.
ParentDatasetQueryResults
(db: lsst.daf.butler.registry.interfaces._database.Database, query: lsst.daf.butler.registry.queries._query.Query, *, components: Sequence[Optional[str]], records: Optional[Mapping[str, Mapping[tuple, lsst.daf.butler.core.dimensions._records.DimensionRecord]]] = None, datasetType: Optional[lsst.daf.butler.core.datasets.type.DatasetType] = None)¶ Bases:
lsst.daf.butler.registry.queries.DatasetQueryResults
An object that represents results from a query for datasets with a single parent
DatasetType
.Parameters: - db :
Database
Database engine to execute queries against.
- query :
Query
Low-level query object that backs these results.
query.datasetType
will be the parent dataset type for this object, and may not beNone
.- components :
Sequence
[str
orNone
] Names of components to include in iteration.
None
may be included (at most once) to include the parent dataset type.- records :
Mapping
, optional Mapping containing
DimensionRecord
objects for all dimensions and all data IDs this query will yield. IfNone
(default),DataCoordinate.hasRecords
will returnFalse
for all nested data IDs. This is a nested mapping withstr
names of dimension elements as outer keys,DimensionRecord
instances as inner values, andtuple(record.dataId.values())
for the inner keys / outer values (whererecord
is the innermostDimensionRecord
instance).- datasetType :
DatasetType
, optional Parent dataset type for all datasets returned by this query. If not provided,
query.datasetType
be used, and must not beNone
(as it is in the case where the query is known to yield no results prior to execution).
Attributes Summary
dataIds
A lazy-evaluation object representing a query for just the data IDs of the datasets that would be returned by this query ( DataCoordinateQueryResults
).parentDatasetType
The parent dataset type for all datasets in this iterable ( DatasetType
).Methods Summary
any
(*, execute, exact)Test whether this query returns any results. byParentDatasetType
()Group results by parent dataset type. count
(*, exact)Count the number of rows this query would return. expanded
()Return a DatasetQueryResults
for whichDataCoordinate.hasRecords
returnsTrue
for all data IDs in returnedDatasetRef
objects.explain_no_results
()Return human-readable messages that may help explain why the query yields no results. materialize
()Insert this query’s results into a temporary table. withComponents
(components)Return a new query results object for the same parent datasets but different components. Attributes Documentation
-
dataIds
¶ A lazy-evaluation object representing a query for just the data IDs of the datasets that would be returned by this query (
DataCoordinateQueryResults
).The returned object is not in general
zip
-iterable withself
; it may be in a different order or have (or not have) duplicates.
-
parentDatasetType
¶ The parent dataset type for all datasets in this iterable (
DatasetType
).
Methods Documentation
-
any
(*, execute: bool = True, exact: bool = True) → bool¶ Test whether this query returns any results.
Parameters: - execute :
bool
, optional If
True
, execute at least aLIMIT 1
query if it cannot be determined prior to execution that the query would return no rows.- exact :
bool
, optional If
True
, run the full query and perform post-query filtering if needed, until at least one result row is found. IfFalse
, the returned result does not account for post-query filtering, and hence may beTrue
even when all result rows would be filtered out.
Returns: - execute :
-
byParentDatasetType
() → Iterator[lsst.daf.butler.registry.queries._results.ParentDatasetQueryResults]¶ Group results by parent dataset type.
Returns: - iter :
Iterator
[ParentDatasetQueryResults
] An iterator over
DatasetQueryResults
instances that are each responsible for a single parent dataset type (either just that dataset type, one or more of its component dataset types, or both).
- iter :
-
count
(*, exact: bool = True) → int¶ Count the number of rows this query would return.
Parameters: Returns: - count :
int
The number of rows the query would return, or an upper bound if
exact=False
.
Notes
This counts the number of rows returned, not the number of unique rows returned, so even with
exact=True
it may provide only an upper bound on the number of deduplicated result rows.- count :
-
expanded
() → lsst.daf.butler.registry.queries._results.ParentDatasetQueryResults¶ Return a
DatasetQueryResults
for whichDataCoordinate.hasRecords
returnsTrue
for all data IDs in returnedDatasetRef
objects.Returns: - expanded :
DatasetQueryResults
Either a new
DatasetQueryResults
instance orself
, if it is already expanded.
Notes
As with
DataCoordinateQueryResults.expanded
, it may be more efficient to callmaterialize
before expanding data IDs for very large result sets.- expanded :
-
explain_no_results
() → Iterator[str]¶ Return human-readable messages that may help explain why the query yields no results.
Returns: - messages :
Iterator
[str
] String messages that describe reasons the query might not yield any results.
Notes
Messages related to post-query filtering are only available if the iterator has been exhausted, or if
any
orcount
was already called (withexact=True
for the latter two).At present, this method only returns messages that are generated while the query is being built or filtered. In the future, it may perform its own new follow-up queries, which users may wish to short-circuit simply by not continuing to iterate over its results.
- messages :
-
materialize
() → Iterator[lsst.daf.butler.registry.queries._results.ParentDatasetQueryResults]¶ Insert this query’s results into a temporary table.
Returns: - context :
typing.ContextManager
[DatasetQueryResults
] A context manager that ensures the temporary table is created and populated in
__enter__
(returning a results object backed by that table), and dropped in__exit__
. Ifself
is already materialized, the context manager may do nothing (reflecting the fact that an outer context manager should already take care of everything else).
- context :
-
withComponents
(components: Sequence[Optional[str]]) → lsst.daf.butler.registry.queries._results.ParentDatasetQueryResults¶ Return a new query results object for the same parent datasets but different components.
- db :