From 8207f279deeb36d70bc527a35f99bf87c2584fa5 Mon Sep 17 00:00:00 2001 From: Krzysztof Findeisen Date: Thu, 23 Jan 2025 11:28:24 -0800 Subject: [PATCH] Document preconditions for iterating over GeneralQueryResults. GeneralQueryResults.iter_tuple (and DatasetAssociation.from_query_result, which calls it) assume dataset_id and run columns for the dataset type(s) of interest. However, these columns do not exist unless the query call specifically asks for them. --- python/lsst/daf/butler/_dataset_association.py | 9 +++++---- python/lsst/daf/butler/queries/_general_query_results.py | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python/lsst/daf/butler/_dataset_association.py b/python/lsst/daf/butler/_dataset_association.py index 6572fe0c38..f08483bd03 100644 --- a/python/lsst/daf/butler/_dataset_association.py +++ b/python/lsst/daf/butler/_dataset_association.py @@ -72,10 +72,11 @@ def from_query_result( Parameters ---------- - result : `GeneralQueryResults` - General query result returned by `Query.general` method. The result - has to include "{dataset_type.name}.timespan" and - "{dataset_type.name}.collection" columns. + result : `~lsst.daf.butler.queries.GeneralQueryResults` + General query result returned by + `Query.general ` method. The + result has to include "dataset_id", "run", "collection", and + "timespan" dataset fields for ``dataset_type``. dataset_type : `DatasetType` Dataset type, query has to include this dataset type. """ diff --git a/python/lsst/daf/butler/queries/_general_query_results.py b/python/lsst/daf/butler/queries/_general_query_results.py index 021d3df8bd..68a1d45b55 100644 --- a/python/lsst/daf/butler/queries/_general_query_results.py +++ b/python/lsst/daf/butler/queries/_general_query_results.py @@ -111,6 +111,9 @@ def iter_tuples(self, *dataset_types: DatasetType) -> Iterator[GeneralResultTupl """Iterate over result rows and return data coordinate, and dataset refs constructed from each row, and an original row. + This object has to include "dataset_id" and "run" columns for each type + in ``dataset_types``. + Parameters ---------- *dataset_types : `DatasetType`