Skip to content

feat: grain-aware join_one via is_entity dimensions#219

Merged
hussainsultan merged 2 commits intomainfrom
worktree-issue-218-grain-aware-joins
Apr 15, 2026
Merged

feat: grain-aware join_one via is_entity dimensions#219
hussainsultan merged 2 commits intomainfrom
worktree-issue-218-grain-aware-joins

Conversation

@hachej
Copy link
Copy Markdown
Collaborator

@hachej hachej commented Mar 24, 2026

Summary

Closes #218
Closes #223
Related: #64 — this PR lays the groundwork for deferred join_one optimization by establishing is_entity as the primary key / grain concept

Changes

  • is_entity attribute on Dimension marks primary-key / grain columns
  • join_one() auto-detects grain mismatch via entity dim comparison and upgrades to join_many with a warning
  • Cardinality serialized in join metadata; missing cardinality defaults to "many" (safe for legacy payloads)

@pieter-factful
Copy link
Copy Markdown

Proposed solution is clean and the outcome intuitive for users. I'm not familiar with entity in this context however, why not defines_pk,sets_grain or similar?

And how would this work for 'equivalent' columns? I imagine having both month (1,2,3,..) and period (p1,p2,p3,..). Mark both is_entity=true?

Note that I'm still studying BSLs internals and do not fully understand the inner workings yet. But i feel there should be an even more intuitive way. Something like pre-aggregation by default, using the columns used in the join.

@boringdata boringdata force-pushed the worktree-issue-218-grain-aware-joins branch from 731d8f3 to deccd95 Compare April 1, 2026 18:59
boringdata and others added 2 commits April 14, 2026 13:03
)

Pre-existing tagged payloads serialized before cardinality was emitted
have no 'cardinality' key. Defaulting to 'one' would silently skip
pre-aggregation on former join_many joins. Default to 'many' instead
since it is the safe superset.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@boringdata boringdata force-pushed the worktree-issue-218-grain-aware-joins branch from 82ca324 to 1b4f5fb Compare April 14, 2026 13:05
@hussainsultan hussainsultan merged commit 0fbf06e into main Apr 15, 2026
3 checks passed
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.

Serialization: missing cardinality in pre-existing tagged joins defaults to 'one' Multi-fact star schema: auto-aggregate to align grains before join

4 participants