Skip to content

Commit

Permalink
Make order-by error more informative
Browse files Browse the repository at this point in the history
Add a description of which columns are invalid and which are allowed when an order by expression is not legal.
  • Loading branch information
dhirving committed Nov 8, 2024
1 parent 14ba778 commit c077b29
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/lsst/daf/butler/queries/result_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ def validate_tree(self, tree: QueryTree) -> None:
for term in spec.order_by:
term.gather_required_columns(order_by_columns)
if not (order_by_columns.dimensions <= spec.dimensions):
allowed_columns = spec.dimensions.names
invalid_columns = order_by_columns.dimensions.names - allowed_columns
raise InvalidQueryError(
"Order-by expression may not reference columns that are not in the result dimensions."
"Order-by expression may not reference columns that are not in the result dimensions.\n"
f"Invalid columns: {invalid_columns}\n"
f"Available columns: {allowed_columns}"
)
for dataset_type in order_by_columns.dataset_fields.keys():
if dataset_type not in tree.datasets:
Expand Down

0 comments on commit c077b29

Please sign in to comment.