Skip to content

Add source_column + POST /preaggs/register for external tables#2338

Draft
shangyian wants to merge 2 commits into
DataJunction:mainfrom
shangyian:preagg-register
Draft

Add source_column + POST /preaggs/register for external tables#2338
shangyian wants to merge 2 commits into
DataJunction:mainfrom
shangyian:preagg-register

Conversation

@shangyian

@shangyian shangyian commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a source_column field to PreAggMeasure and a /preaggs/register endpoint that adopts an externally-built pre-aggregation table (one DJ did not generate or run). DJ decomposes the requested metrics into component measures, binds each to a physical column via measure_columns, validates them against the table (every measure_columnskey is anis_measuremetric and every component measure of the requested metrics is covered), records thePreAggregation, and when a valid_through_ts` is supplied, sets availability so grain resolution can route queries to it.

The query builder (get_preagg_measure_column) now prefers a measure's source_column, so registered external columns are used at query time.

Advances #2118.

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

Adds a source_column field to PreAggMeasure and a /preaggs/register
endpoint that adopts an externally-built pre-aggregation table (one DJ
did not generate or run). DJ decomposes the requested metrics into
component measures, binds each to a physical column via measure_columns,
validates them against the table (declared columns exist; every
measure_columns key is an is_measure metric; every component measure of
the requested metrics is covered), records the PreAggregation, and — when
a valid_through_ts is supplied — sets availability so grain resolution can
route queries to it.

The query builder (get_preagg_measure_column) now prefers a measure's
source_column, so registered external columns are used at query time.

No migration: the DJ-generated measures SQL is stored (informational) so
`sql` stays non-null, and external pre-aggs are identified by source_column
presence. EXTERNAL strategy marker, nullable sql, and a stable name column
are deferred to the YAML/reconcile work (PR 4).

Stacked on the is_measure branch. Advances DataJunction#2118.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 94245d7
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6a5ab9e5ceda660008c72d4f

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.

1 participant