-1

We have a use case where we only want to mark only selected rows for deletion based on the value of a non timestamp column (State column) and the time elapsed since the row was created? Is there a way to define conditional TTL in spanner for a row?

In the examples in official documentation, I could only see examples for setting up TTL for all rows based on a timestamp column https://cloud.google.com/spanner/docs/ttl/working-with-ttl#create

1
  • SO is for programming questions Commented Feb 14, 2024 at 7:33

1 Answer 1

0

As documented, Row deletion policies can use generated columns to express more sophisticated rules

You create a generated TIMESTAMP column which generates a timestamp according to your business rule.

In this case you would create an generated 'row expiry timestamp' based on the row creation timestamp and the State column (eg if State is set to the do not delete value, set the timestamp to timestamp-max aka "9999-12-31 23:59:59.999999999 UTC"), and then set a ROW DELETION POLICY on that generated timestamp

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.