googleapis / python-spanner-sqlalchemy

Apache License 2.0
38 stars 28 forks source link

Support for Row Deletion Policy #302

Open jstlaurent opened 1 year ago

jstlaurent commented 1 year ago

Is your feature request related to a problem? Please describe. We have a use case where some entities have a life cycle where they are created, kept alive through a polling mechanism, and then destroyed. In order to handle the case where the client fails to explicitly destroy an entity (through error, network failure, etc.), we have implemented a time-to-live feature that flags entities as stale once they have not received a keep-alive request beyond a certain delay. We currently have a scheduled event that calls a process to remove these stale entities.

Describe the solution you'd like Cloud Spanner supports Row Deletion policies that would let us set the TTL directly in Spanner, without having to manage a scheduled process to do so. This requires adding SQL statements to the table declaration. We would like to be able to add these statements through the declarative __table_args__ field of our SQLAlchemy models, much like interleaving.

Describe alternatives you've considered We can continue to run our scheduled process, but we would prefer to leverage the full capabilities of Spanner going forward.

Additional context None.