DimensionRecordQueryResults

class lsst.daf.butler.DimensionRecordQueryResults

Bases: Iterable[DimensionRecord]

An interface for objects that represent the results of queries for dimension records.

Attributes Summary

element

Dimension element for this result (DimensionElement).

Methods Summary

any(*[, execute, exact])

Test whether this query returns any results.

count(*[, exact, discard])

Count the number of rows this query would return.

explain_no_results([execute])

Return human-readable messages that may help explain why the query yields no results.

limit(limit[, offset])

Make the iterator return limited number of records.

order_by(*args)

Make the iterator return ordered result.

run()

Execute the query and return an instance with data held in memory.

Attributes Documentation

element

Dimension element for this result (DimensionElement).

Methods Documentation

abstract any(*, execute: bool = True, exact: bool = True) bool

Test whether this query returns any results.

Parameters:
executebool, optional

If True, execute at least a LIMIT 1 query if it cannot be determined prior to execution that the query would return no rows.

exactbool, optional

If True, run the full query and perform post-query filtering if needed, until at least one result row is found. If False, the returned result does not account for post-query filtering, and hence may be True even when all result rows would be filtered out.

Returns:
anybool

True if the query would (or might, depending on arguments) yield result rows. False if it definitely would not.

abstract count(*, exact: bool = True, discard: bool = False) int

Count the number of rows this query would return.

Parameters:
exactbool, optional

If True, run the full query and perform post-query filtering if needed to account for that filtering in the count. If False, the result may be an upper bound.

discardbool, optional

If True, compute the exact count even if it would require running the full query and then throwing away the result rows after counting them. If False, this is an error, as the user would usually be better off executing the query first to fetch its rows into a new query (or passing exact=False). Ignored if exact=False.

Returns:
countint

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.

abstract explain_no_results(execute: bool = True) Iterable[str]

Return human-readable messages that may help explain why the query yields no results.

Parameters:
executebool, optional

If True (default) execute simplified versions (e.g. LIMIT 1) of aspects of the tree to more precisely determine where rows were filtered out.

Returns:
messagesIterable [ str ]

String messages that describe reasons the query might not yield any results.

abstract limit(limit: int, offset: int | None = 0) DimensionRecordQueryResults

Make the iterator return limited number of records.

Parameters:
limitint

Upper limit on the number of returned records.

offsetint or None

The number of records to skip before returning at most limit records. None is interpreted the same as zero for backwards compatibility.

Returns:
resultDimensionRecordQueryResults

Returns self instance which is updated to return limited set of records.

Notes

This method can modify the iterator in place and return the same instance. Normally this method is used together with order_by method.

abstract order_by(*args: str) DimensionRecordQueryResults

Make the iterator return ordered result.

Parameters:
*argsstr

Names of the columns/dimensions to use for ordering. Column name can be prefixed with minus (-) to use descending ordering.

Returns:
resultDimensionRecordQueryResults

Returns self instance which is updated to return ordered result.

Notes

This method can modify the iterator in place and return the same instance.

abstract run() DimensionRecordQueryResults

Execute the query and return an instance with data held in memory.

Returns:
resultDimensionRecordQueryResults

Query results, may return self if it has all data in memory already.