Skip to content

Conversation

@shiyasmohd
Copy link
Contributor

@shiyasmohd shiyasmohd commented Feb 10, 2026

  • Split PhysicalTable into two structs:
    • PhysicalTable (logical table entity with dataset metadata and active revision pointer)
    • PhysicalTableRevision (storage revision with path and writer job)
  • Compute active status at query time via EXISTS instead of denormalized column
  • Rename get_by_id to get_active_by_location_id with typed error handling
  • Add tests for inactive revisions, metadata, and writer details"

@shiyasmohd shiyasmohd self-assigned this Feb 10, 2026
@shiyasmohd shiyasmohd requested a review from LNSD February 10, 2026 10:42
@shiyasmohd shiyasmohd marked this pull request as draft February 10, 2026 12:08
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from d71fa32 to 1b78b89 Compare February 10, 2026 14:17
@shiyasmohd shiyasmohd changed the title refactor(metadata-db): split PhysicalTable into table entity and revision refactor(metadata-db): add active column to physical_table_revision Feb 10, 2026
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from 1b78b89 to f870e81 Compare February 10, 2026 14:25
@shiyasmohd shiyasmohd marked this pull request as ready for review February 10, 2026 14:29
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch 2 times, most recently from 8de4d12 to b8d82a4 Compare February 11, 2026 06:55
Copy link
Contributor

@LNSD LNSD left a 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 $1

The 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.

@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from b8d82a4 to 433122a Compare February 11, 2026 09:08
@shiyasmohd shiyasmohd changed the title refactor(metadata-db): add active column to physical_table_revision refactor(metadata-db): decouple PhysicalTable from revision Feb 11, 2026
@shiyasmohd
Copy link
Contributor Author

@LNSD Updated the PR. Removed the migration.

@LNSD
Copy link
Contributor

LNSD commented Feb 11, 2026

@LNSD Updated the PR. Removed the migration.

You also removed dependencies from the providers-* crates that I will need in a follow-up PR 😅

@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from 433122a to f89c467 Compare February 11, 2026 13:12
Copy link
Contributor

@LNSD LNSD left a 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 🙂

@shiyasmohd shiyasmohd requested a review from LNSD February 12, 2026 04:54
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from f89c467 to 02d37dd Compare February 12, 2026 06:25
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from 02d37dd to ae182db Compare February 12, 2026 06:41
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/decouple-phy-table branch from ae182db to d29ef68 Compare February 12, 2026 06:42
Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@shiyasmohd shiyasmohd merged commit 44df411 into main Feb 12, 2026
7 checks passed
@shiyasmohd shiyasmohd deleted the shiyasmohd/decouple-phy-table branch February 12, 2026 06:56
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.

2 participants