Skip to content

feat: Mosaic preagg in an ephemeral database - #585

Merged
ilyabo merged 2 commits into
mainfrom
feat--Mosaic-preagg-in-an-ephemeral-database
May 4, 2026
Merged

ilyabo merged 2 commits into
mainfrom
feat--Mosaic-preagg-in-an-ephemeral-database

Conversation

@ilyabo

@ilyabo ilyabo commented May 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • Pre-aggregation optimization is now configurable, allowing you to redirect pre-aggregates to a custom schema or disable them via configuration options.
  • Documentation

    • Added comprehensive documentation explaining pre-aggregation optimization and how to customize its behavior for your use case.
  • Tests

    • Added test coverage for pre-aggregation configuration.

@coderabbitai

coderabbitai Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@ilyabo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 31 minutes and 20 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90371410-e7a0-4263-a166-79ed67d3b05b

📥 Commits

Reviewing files that changed from the base of the PR and between daeb078 and b24bcd4.

📒 Files selected for processing (1)
  • packages/mosaic/__tests__/MosaicSlice.test.ts
📝 Walkthrough

Walkthrough

This PR adds pre-aggregation configuration support to Mosaic by introducing a new MosaicPreAggregateOptions type that allows callers to specify a custom schema and enable/disable setting. The CLI app attaches an in-memory database with a pre-aggregation schema and wires it through the Mosaic slice initialization.

Changes

Pre-Aggregation Configuration

Layer / File(s) Summary
Type Definition
packages/mosaic/src/MosaicSlice.ts
MosaicPreAggregateOptions type introduced with optional schema and enabled fields; CreateMosaicSliceProps updated to accept preagg option.
Core Implementation
packages/mosaic/src/MosaicSlice.ts
Internal helper applyMosaicPreAggregateOptions() conditionally sets preaggregator.schema and enabled on the coordinator. Applied in both coordinator paths during initialize().
Type Export
packages/mosaic/src/index.ts
MosaicPreAggregateOptions type re-exported for public use.
CLI Integration
apps/sqlrooms-cli-ui/src/store.ts
DuckDB initialization attaches an in-memory database and creates mosaic schema. Mosaic slice initialized with preagg config pointing to that schema.
Tests & Documentation
packages/mosaic/__tests__/MosaicSlice.test.ts, packages/mosaic/README.md
New test verifies pre-aggregation options are correctly applied to the coordinator. README documents pre-aggregation caching behavior, lazy cache creation, default schema, and configuration options.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#408: Adds Mosaic integration to the CLI store with DuckDB connector support and slice creation, providing context for the pre-aggregation configuration introduced here.

Poem

A rabbit hops through schemas bright,
With pre-aggregates cached just right,
In memory's meadow, Mosaic springs free,
Configuration flows—one, two, three! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Mosaic preagg in an ephemeral database' directly describes the main change: configuring Mosaic pre-aggregation to use an ephemeral (in-memory) database instead of persistent storage, as evidenced by the store initialization changes and new preagg configuration options.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat--Mosaic-preagg-in-an-ephemeral-database

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 31 minutes and 20 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/mosaic/__tests__/MosaicSlice.test.ts (1)

9-20: 💤 Low value

Consider adding test cases for partial configuration.

The current test covers both options together. Additional tests for edge cases (only schema, only enabled, or undefined preagg) would improve confidence, though the implementation's guards are straightforward.

💡 Example additional test cases
it('applies only schema when enabled is omitted', async () => {
  const coordinator = new Coordinator();
  const store = createStore<BaseRoomStoreState & MosaicSliceState>()((...args) => ({
    ...createBaseRoomSlice()(...args),
    ...createMosaicSlice({
      coordinator,
      preagg: { schema: 'custom.schema' },
    })(...args),
  }));

  await store.getState().mosaic.initialize();

  expect(coordinator.preaggregator.schema).toBe('custom.schema');
  // enabled should remain at Mosaic's default
});

it('preserves defaults when preagg is omitted', async () => {
  const coordinator = new Coordinator();
  const defaultSchema = coordinator.preaggregator.schema;
  const store = createStore<BaseRoomStoreState & MosaicSliceState>()((...args) => ({
    ...createBaseRoomSlice()(...args),
    ...createMosaicSlice({ coordinator })(...args),
  }));

  await store.getState().mosaic.initialize();

  expect(coordinator.preaggregator.schema).toBe(defaultSchema);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mosaic/__tests__/MosaicSlice.test.ts` around lines 9 - 20, Add
focused tests that exercise partial preagg configs: create variants of
createTestStore using createMosaicSlice with preagg containing only schema, only
enabled, and with preagg omitted; for each, call
store.getState().mosaic.initialize() (or mosaic.initialize) and assert
Coordinator.preaggregator.schema and enabled reflect only the provided fields
(e.g., schema set when given, enabled left as default when omitted, and defaults
preserved when preagg is undefined). Use Coordinator and createBaseRoomSlice
references from the existing helper to build the store and keep assertions
minimal and targeted to the preagg behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/mosaic/__tests__/MosaicSlice.test.ts`:
- Around line 9-20: Add focused tests that exercise partial preagg configs:
create variants of createTestStore using createMosaicSlice with preagg
containing only schema, only enabled, and with preagg omitted; for each, call
store.getState().mosaic.initialize() (or mosaic.initialize) and assert
Coordinator.preaggregator.schema and enabled reflect only the provided fields
(e.g., schema set when given, enabled left as default when omitted, and defaults
preserved when preagg is undefined). Use Coordinator and createBaseRoomSlice
references from the existing helper to build the store and keep assertions
minimal and targeted to the preagg behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66f835f7-e537-400c-a8d8-c04c103804e4

📥 Commits

Reviewing files that changed from the base of the PR and between 134461c and daeb078.

📒 Files selected for processing (5)
  • apps/sqlrooms-cli-ui/src/store.ts
  • packages/mosaic/README.md
  • packages/mosaic/__tests__/MosaicSlice.test.ts
  • packages/mosaic/src/MosaicSlice.ts
  • packages/mosaic/src/index.ts

@ilyabo
ilyabo merged commit 0262bac into main May 4, 2026
3 checks passed
@ilyabo
ilyabo deleted the feat--Mosaic-preagg-in-an-ephemeral-database branch May 4, 2026 20:05
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