-
Notifications
You must be signed in to change notification settings - Fork 4
refactor(metadata-db): decouple PhysicalTable from revision #1717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d71fa32 to
1b78b89
Compare
active column to physical_table_revision
1b78b89 to
f870e81
Compare
8de4d12 to
b8d82a4
Compare
LNSD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this second migration? The active status is already derivable at query time from physical_tables.active_revision_id: either via (pt.active_revision_id = ptr.id) AS active in JOINs or an EXISTS subquery.
For example, the list query could be:
SELECT
ptr.id,
ptr.path,
EXISTS(SELECT 1 FROM physical_tables WHERE active_revision_id = ptr.id) AS active,
ptr.writer,
ptr.metadata
FROM physical_table_revisions ptr
ORDER BY ptr.id DESC
LIMIT $1The denormalized column + trigger adds schema surface and sync complexity for a JOIN that's cheap (small table, indexed FK). I'd lean toward dropping the second migration entirely and just computing active in the queries.
b8d82a4 to
433122a
Compare
active column to physical_table_revision|
@LNSD Updated the PR. Removed the migration. |
You also removed dependencies from the |
433122a to
f89c467
Compare
LNSD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check my comments 🙂
f89c467 to
02d37dd
Compare
02d37dd to
ae182db
Compare
ae182db to
d29ef68
Compare
LNSD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
PhysicalTableinto two structs:PhysicalTable(logical table entity with dataset metadata and active revision pointer)PhysicalTableRevision(storage revision with path and writer job)activestatus at query time via EXISTS instead of denormalized columnget_by_idtoget_active_by_location_idwith typed error handling