Skip to content

Commit

Permalink
Enforce limitations on dimensions in query system.
Browse files Browse the repository at this point in the history
I plan to remove these limitations on a future ticket, but for now it's
better to fail early rather than produce some confusing error message
or (more likely and worse) unexpected query later.
  • Loading branch information
TallJimbo committed Aug 7, 2020
1 parent 505ca97 commit 3197537
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/lsst/daf/butler/registry/queries/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def joinTable(self, table: sqlalchemy.sql.FromClause, dimensions: NamedValueSet[
datasets : `DatasetQueryColumns`, optional
Columns that identify a dataset that is part of the query results.
"""
if not dimensions.issubset(self.summary.requested.dimensions):
raise NotImplementedError(
"QueryBuilder does not yet support joining in dimensions that were not provided "
"originally to the QuerySummary object passed at construction."
)
joinOn = self.startJoin(table, dimensions, dimensions.names)
self.finishJoin(table, joinOn)
if datasets is not None:
Expand Down
9 changes: 9 additions & 0 deletions python/lsst/daf/butler/registry/queries/_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@ def makeBuilder(self, summary: Optional[QuerySummary] = None) -> QueryBuilder:
from ._builder import QueryBuilder
if summary is None:
summary = QuerySummary(self.graph, whereRegion=self.whereRegion)
if not summary.requested.issubset(self.graph):
raise NotImplementedError("Query.makeBuilder does not yet support "
"augmentation to new dimensions.")
builder = QueryBuilder(summary, managers=self.managers)
builder.joinTable(self.sql.alias(), dimensions=self.graph.dimensions,
datasets=self.getDatasetColumns())
Expand Down Expand Up @@ -810,6 +813,9 @@ def makeBuilder(self, summary: Optional[QuerySummary] = None) -> QueryBuilder:
from ._builder import QueryBuilder
if summary is None:
summary = QuerySummary(self.graph, whereRegion=self.whereRegion)
if not summary.requested.issubset(self.graph):
raise NotImplementedError("Query.makeBuilder does not yet support "
"augmentation to new dimensions.")
builder = QueryBuilder(summary, managers=self.managers)
builder.joinTable(self._table, dimensions=self.graph.dimensions, datasets=self.getDatasetColumns())
return builder
Expand Down Expand Up @@ -877,4 +883,7 @@ def makeBuilder(self, summary: Optional[QuerySummary] = None) -> QueryBuilder:
from ._builder import QueryBuilder
if summary is None:
summary = QuerySummary(self.graph)
if not summary.requested.issubset(self.graph):
raise NotImplementedError("Query.makeBuilder does not yet support "
"augmentation to new dimensions.")
return QueryBuilder(summary, managers=self.managers)

0 comments on commit 3197537

Please sign in to comment.