Skip to content

Commit c077b29

Browse files
committed
Make order-by error more informative
Add a description of which columns are invalid and which are allowed when an order by expression is not legal.
1 parent 14ba778 commit c077b29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/lsst/daf/butler/queries/result_specs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ def validate_tree(self, tree: QueryTree) -> None:
8686
for term in spec.order_by:
8787
term.gather_required_columns(order_by_columns)
8888
if not (order_by_columns.dimensions <= spec.dimensions):
89+
allowed_columns = spec.dimensions.names
90+
invalid_columns = order_by_columns.dimensions.names - allowed_columns
8991
raise InvalidQueryError(
90-
"Order-by expression may not reference columns that are not in the result dimensions."
92+
"Order-by expression may not reference columns that are not in the result dimensions.\n"
93+
f"Invalid columns: {invalid_columns}\n"
94+
f"Available columns: {allowed_columns}"
9195
)
9296
for dataset_type in order_by_columns.dataset_fields.keys():
9397
if dataset_type not in tree.datasets:

0 commit comments

Comments
 (0)