rusackas commented on code in PR #40671:
URL: https://github.com/apache/superset/pull/40671#discussion_r3350454523
##########
superset/key_value/shared_entries.py:
##########
@@ -86,6 +86,19 @@ def set_shared_value(key: SharedKey, value: Any) -> None:
KeyValueDAO.create_entry(RESOURCE, value, CODEC, uuid_key)
+@transaction()
+def upsert_shared_value(key: SharedKey, value: Any) -> None:
+ """
+ Create or update a shared value by key, using the current hash algorithm.
+
+ Unlike :func:`set_shared_value`, this is idempotent and may be called
+ repeatedly to overwrite an existing entry.
+ """
+ namespace = get_uuid_namespace("")
+ uuid_key = uuid3(namespace, key)
+ KeyValueDAO.upsert_entry(RESOURCE, value, CODEC, uuid_key)
Review Comment:
Good call — added dedicated unit tests for `upsert_shared_value` covering
both the create/update delegation path and the repeated-overwrite (idempotent)
behavior in `tests/unit_tests/key_value/test_shared_entries_migration.py`. Done
in this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]