Skip to content

refactor(core): derive Default for CubeQuery - #2722

Open
goldmedal wants to merge 1 commit into
mainfrom
feat/core-cube-query-default
Open

refactor(core): derive Default for CubeQuery#2722
goldmedal wants to merge 1 commit into
mainfrom
feat/core-cube-query-default

Conversation

@goldmedal

@goldmedal goldmedal commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • derive Default for CubeQuery
  • construct CubeQuery via ..Default::default() in the two existing struct literals

Why

Follow-up on the review of #2677. CubeQuery is a public type with all-public fields, so a struct literal has to name every field. Adding orderBy in #2677 was therefore a source-breaking change for anyone constructing a CubeQuery directly.

Every field already satisfies Default, so the derive costs nothing and lets callers name only the fields they care about:

let query = CubeQuery {
    cube: "OrdersCube".to_string(),
    measures: vec!["revenue".to_string()],
    dimensions: vec!["status".to_string()],
    order_by: vec![CubeOrderBy {
        member: "revenue".to_string(),
        direction: SortDirection::Desc,
    }],
    ..Default::default()
};

Future optional fields then stay additive rather than breaking downstream builds.

No behavioural change: #[derive(Default)] only generates impl Default for CubeQuery. Field-level #[serde(default)] already resolved against each field's Default, so deserialization is untouched.

Validation

  • cargo fmt --all -- --check
  • cargo check --all-targets
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --lib --tests --bins — lib 160 passed, cube_public_api 1 passed, sqllogictests passed
  • wren-core-py: cargo test 37 passed, maturin develop + pytest 46 passed (incl. 13 cube binding tests)
  • Mutation check that the derive is load-bearing, not merely exercised: removing it fails compilation at both call sites — error[E0277]: the trait bound CubeQuery: Default is not satisfied at core/src/mdl/cube.rs:654 and core/tests/cube_public_api.rs:34.

Summary by CodeRabbit

  • Improvements
    • Cube queries can now be initialized with default values, making it easier to add optional query fields without requiring updates to existing callers.
    • Added guidance for constructing cube queries using default values.

Callers had to name every field of the struct literal, so #2677 adding
orderBy was a source-breaking change for anyone constructing a CubeQuery
directly. Every field already satisfies Default, so the derive is free and
lets callers write `..Default::default()` — future optional fields then
stay additive.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added rust Pull requests that update rust code core labels Sep 2, 2026
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: e99c471f-e2b4-4f0c-a7b6-2bb6f008d5f7

📥 Commits

Reviewing files that changed from the base of the PR and between 8d23753 and a177279.

📒 Files selected for processing (2)
  • core/wren-core/core/src/mdl/cube.rs
  • core/wren-core/core/tests/cube_public_api.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

CubeQuery now derives Default and documents struct-update construction. Internal and public API test construction uses ..Default::default() for unspecified fields.

Changes

CubeQuery default construction

Layer / File(s) Summary
Add default construction and update callers
core/wren-core/core/src/mdl/cube.rs, core/wren-core/core/tests/cube_public_api.rs
CubeQuery derives Default and documents default-based struct updates. Test constructions now specify only non-default fields.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to a1772

This change makes CubeQuery construction more compatible without changing query validation, SQL generation, or runtime behavior. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: byjoh

Poem

A rabbit taps Default with care
Empty fields need not fill the air
Order stays clear
New options draw near
Struct updates hop everywhere

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: deriving Default for CubeQuery.
Description check ✅ Passed The description explains the change, motivation, absence of behavioral changes, validation steps, and mutation check. It does not include an explicit Duplicate check section, but the description is ot…
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.
Full details: Description check

Explanation

The description explains the change, motivation, absence of behavioral changes, validation steps, and mutation check. It does not include an explicit Duplicate check section, but the description is otherwise complete and directly related to the pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/core-cube-query-default

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

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

@goldmedal
goldmedal requested a review from douenergy September 2, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant