Skip to content

Change enum on history events to str#1379

Draft
samredai wants to merge 3094 commits intoDataJunction:mainfrom
samredai:enum-to-str
Draft

Change enum on history events to str#1379
samredai wants to merge 3094 commits intoDataJunction:mainfrom
samredai:enum-to-str

Conversation

@samredai
Copy link
Copy Markdown
Contributor

@samredai samredai commented May 14, 2025

Summary

This changes the enum type for activity type and entity type to a string, only in the database model. This will let us modify/extend the history events in the source code more easily without having to do database migrations.

Test Plan

Deployment Plan

GitHub Actions Bot and others added 30 commits December 18, 2024 21:49
…on-0.0.1a79

Bump DataJunction version to 0.0.1a79
Make measures derived from metrics unique based on the expression
Support displaying markdown in node descriptions in the UI
…on-0.0.1a80

Bump DataJunction version to 0.0.1a80
Add is_hidden to DimensionAttributeOutput
…on-0.0.1a81

Bump DataJunction version to 0.0.1a81
agorajek and others added 22 commits March 26, 2025 00:37
Co-authored-by: GitHub Actions Bot <>
* Add metric formatting metadata like significant digits and controls for using scientific notation

* Add tests for sig figs

* Add UI support for editing metric sigfigs

* Fix client

* Fix lint
Co-authored-by: GitHub Actions Bot <>
* Fix bug where editing a cube node with a materialization configured can error out based on there being no lookback_window

* Fix and add new tests

* Lint
…ed characters in the name (DataJunction#1363)

* Include measures columns even when they contain reserved character sequences

* Change logic to handle cases where there is a _DOT_ in the measure column name
* Add support for surfacing primary key in GQL

* Speed up loading of the edit metric UI by retrieving only relevant fields via GQL

* Fix lint and add test

* Fix unit tests

* Remove console.log
Co-authored-by: GitHub Actions Bot <>
* Support setting necessary levels for measures with DISTINCT aggregations

* Add tests for decomposing to necessary levels for measures with DISTINCT aggregations

* Make sure that preaggregate SQL generation takes into account measures levels

* Add tests for distinct pre-agg handling
* Cache metrics list endpoint

* Test that cache is hit on multiple calls to /metrics

* Add a sleep to let background task cache finish in test

* detect cache hit by counting list_nodes calls

* Use mocker from pytest_mock

* Switch to using standard module__client fixture

* fix test
* Add support to execute database statement with retry logic for transient errors

* Add support to execute database statement with retry logic for transient errors
Co-authored-by: GitHub Actions Bot <>
* node button cleanup & watch button

* tag event type not create

* lint

* yarn lint

* on_conflict_do_update

* Fix unique key on notification preferences table

* fix tests

* lint

* lint

---------

Co-authored-by: samredai <sredai@netflix.com>
* Add detailed history for cube node changes

* Add more metadata to cube updates
* Display multiple dimension links in node columns tab

* Fix lint

* Remove extraneous

* Support ability to link (or unlink) multiple simple dimension links

* Clean up

* Fix unit tests

* Fix missing set prototype difference func

* Fix missing set prototype difference func
Co-authored-by: GitHub Actions Bot <>
* Add limit to findNodes GQL query

* Add test coverage
Co-authored-by: GitHub Actions Bot <>
@netlify
Copy link
Copy Markdown

netlify bot commented May 14, 2025

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 8083a48
🔍 Latest deploy log https://app.netlify.com/sites/thriving-cassata-78ae72/deploys/6824bec8b73eae0008abdffc

with op.batch_alter_table("history", schema=None) as batch_op:
batch_op.alter_column(
"entity_type",
existing_type=postgresql.ENUM(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also drop the enum types from Postgres? Maybe with something like:

batch_op.execute("DROP TYPE IF EXISTS entitytype")
batch_op.execute("DROP TYPE IF EXISTS activitytype")

Copy link
Copy Markdown
Member

@agorajek agorajek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samredai this looks good, but I think you should try running this locally and post the outcome on the PR. Just left one comment inline.

entity_type: Mapped[Optional[EntityType]] = mapped_column(
Enum(EntityType),
entity_type: Mapped[Optional[str]] = mapped_column(
String(20),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only 20?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, I just thought that the postgres default of infinite length seemed unnecessary for what will just be a string representation of an enum value. Should I make this larger? Or maybe don't specify the length at all?

@samredai
Copy link
Copy Markdown
Contributor Author

@samredai this looks good, but I think you should try running this locally and post the outcome on the PR. Just left one comment inline.

Good idea, let me populate it with enum values locally then run a migration and see what happens to the data.

@agorajek
Copy link
Copy Markdown
Member

@samredai is this still on your radar? That seems like a good idea.

@samredai
Copy link
Copy Markdown
Contributor Author

@agorajek thanks for the reminder comment. Time was tight this past week but I'll try to do this testing soon and get this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants