Skip to content

Commit

Permalink
ENH: Store event kind in a separate column
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Add a `kind` column to the BigQuery table the event handler feeds and migrate the "kind" key/value out of the `event` column into it.
  • Loading branch information
cortadocodes committed Apr 17, 2024
1 parent 66f170c commit cbd8c11
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions functions/event_handler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def store_pub_sub_event_in_bigquery(cloud_event):
row = {
"datetime": attributes.pop("datetime"),
"uuid": attributes.pop("uuid"),
"kind": event.pop("kind"),
"event": event,
"other_attributes": attributes,
# Pull out some attributes into columns for querying.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="twined-gcp",
version="0.4.0",
version="0.5.0",
author="Marcus Lugg <[email protected]>",
install_requires=[
"setuptools",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_store_pub_sub_event_in_bigquery(self):
cloud_event = MockCloudEvent(
data={
"message": {
"data": base64.b64encode(b'{"some": "data"}'),
"data": base64.b64encode(b'{"kind": "heart", "some": "data"}'),
"attributes": {
"datetime": "2024-04-11T09:26:39.144818",
"uuid": "c8bda9fa-f072-4330-92b1-96920d06b28d",
Expand Down Expand Up @@ -44,6 +44,7 @@ def test_store_pub_sub_event_in_bigquery(self):
{
"datetime": "2024-04-11T09:26:39.144818",
"uuid": "c8bda9fa-f072-4330-92b1-96920d06b28d",
"kind": "heart",
"event": {"some": "data"},
"other_attributes": {
"forward_logs": True,
Expand Down

0 comments on commit cbd8c11

Please sign in to comment.