Skip to content

Commit

Permalink
Add table property to DimensionRecordStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Dec 27, 2023
1 parent 13c9c4c commit d6fd3fb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
5 changes: 5 additions & 0 deletions python/lsst/daf/butler/registry/dimensions/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def element(self) -> DatabaseDimensionElement:
# Docstring inherited from DimensionRecordStorage.element.
return self._nested.element

@property
def table(self) -> sqlalchemy.Table:
# Docstring inherited from DimensionRecordStorage.
return self._nested.table

def clearCaches(self) -> None:
# Docstring inherited from DimensionRecordStorage.clearCaches.
self._cache = None
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/registry/dimensions/governor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def element(self) -> GovernorDimension:
return self._dimension

@property
def table(self) -> sqlalchemy.schema.Table:
def table(self) -> sqlalchemy.Table:
# Docstring inherited from DimensionRecordStorage.
return self._table

def registerInsertionListener(self, callback: Callable[[DimensionRecord], None]) -> None:
Expand Down
5 changes: 5 additions & 0 deletions python/lsst/daf/butler/registry/dimensions/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def element(self) -> DatabaseDimension:
# Docstring inherited from DimensionRecordStorage.element.
return self._element

@property
def table(self) -> sqlalchemy.Table:
# Docstring inherited from DimensionRecordStorage.
return self._target.table

def clearCaches(self) -> None:
# Docstring inherited from DimensionRecordStorage.clearCaches.
pass
Expand Down
5 changes: 5 additions & 0 deletions python/lsst/daf/butler/registry/dimensions/skypix.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def element(self) -> SkyPixDimension:
# Docstring inherited from DimensionRecordStorage.element.
return self._dimension

@property
def table(self) -> sqlalchemy.Table:
# Docstring inherited from DimensionRecordStorage.
raise AssertionError("SkyPix dimensions do not have SQL tables.")

def clearCaches(self) -> None:
# Docstring inherited from DimensionRecordStorage.clearCaches.
pass
Expand Down
5 changes: 5 additions & 0 deletions python/lsst/daf/butler/registry/dimensions/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ def element(self) -> DatabaseDimensionElement:
# Docstring inherited from DimensionRecordStorage.element.
return self._element

@property
def table(self) -> sqlalchemy.Table:
# Docstring inherited from DimensionRecordStorage.
return self._table

def clearCaches(self) -> None:
# Docstring inherited from DimensionRecordStorage.clearCaches.
pass
Expand Down
18 changes: 10 additions & 8 deletions python/lsst/daf/butler/registry/interfaces/_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ def join(
"""
raise NotImplementedError()

@property
@abstractmethod
def table(self) -> sqlalchemy.Table:
"""The SQLAlchemy table that holds this elements records.
This property should raise when accessed if
`DimensionElement.hasTable` is not `True`.
"""
raise NotImplementedError()

@abstractmethod
def insert(self, *records: DimensionRecord, replace: bool = False, skip_existing: bool = False) -> None:
"""Insert one or more records into storage.
Expand Down Expand Up @@ -332,14 +342,6 @@ def element(self) -> GovernorDimension:
# Docstring inherited from DimensionRecordStorage.
raise NotImplementedError()

@property
@abstractmethod
def table(self) -> sqlalchemy.schema.Table:
"""The SQLAlchemy table that backs this dimension
(`sqlalchemy.schema.Table`).
"""
raise NotImplementedError()

def join(
self,
target: Relation,
Expand Down

0 comments on commit d6fd3fb

Please sign in to comment.