Skip to content

✨ add list_cubes method to client#6

Merged
rafaelleinio merged 3 commits into
wandercom:mainfrom
joao-victor-campos:feature/add-list_cubes
May 18, 2026
Merged

✨ add list_cubes method to client#6
rafaelleinio merged 3 commits into
wandercom:mainfrom
joao-victor-campos:feature/add-list_cubes

Conversation

@joao-victor-campos
Copy link
Copy Markdown
Contributor

@joao-victor-campos joao-victor-campos commented May 18, 2026

Note

Low Risk
Low risk, additive change that introduces a new metadata call and data models without altering existing query execution logic.

Overview
Adds a new async list_cubes() client method that calls CubeJS GET /cubejs-api/v1/meta with the same retry/error-handling behavior as get_measures, returning a typed CubeJSMetaResponse.

Introduces Pydantic metadata models (CubeJSMetaCube, CubeJSMetaMeasure, CubeJSMetaDimension, CubeJSMetaSegment) with alias support for CubeJS field names, exports them from cubejs.__init__, and adds unit tests covering successful parsing/serialization and 400-error handling. Also updates uv.lock (dependency metadata churn).

Reviewed by Cursor Bugbot for commit a324296. Bugbot is set up for automated code reviews on this repo. Configure here.

Implements meta endpoint as a list cubes method

Comment thread cubejs/client.py Outdated
Comment on lines +111 to +113
cube["name"]
for cube in response.json().get("cubes", [])
if isinstance(cube, dict) and isinstance(cube.get("name"), str)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you structure the response as pydantic model? it's the pattern we use for other requests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread cubejs/model.py Outdated
Comment on lines +248 to +250
measures: list["CubeJSMetaMeasure"] = Field(default_factory=list)
dimensions: list["CubeJSMetaDimension"] = Field(default_factory=list)
segments: list["CubeJSMetaSegment"] = Field(default_factory=list)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if you use from __future__ import annotations you don't need to use this string reference here, it could be just list[CubeJSMetaMeasure]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done!

Comment thread cubejs/model.py
Comment on lines +256 to +306
class CubeJSMetaMeasure(BaseModel):
"""CubeJS measure metadata."""

name: str
title: str
type: str
short_title: str | None = Field(default=None, alias="shortTitle")
alias_name: str | None = Field(default=None, alias="aliasName")
agg_type: str | None = Field(default=None, alias="aggType")
drill_members: list[str] = Field(default_factory=list, alias="drillMembers")

class Config: # noqa: D106
populate_by_name = True


class CubeJSMetaDimension(BaseModel):
"""CubeJS dimension metadata."""

name: str
title: str
type: str
short_title: str | None = Field(default=None, alias="shortTitle")
alias_name: str | None = Field(default=None, alias="aliasName")
suggest_filter_values: bool | None = Field(
default=None, alias="suggestFilterValues"
)

class Config: # noqa: D106
populate_by_name = True


class CubeJSMetaSegment(BaseModel):
"""CubeJS segment metadata."""

name: str
title: str
short_title: str | None = Field(default=None, alias="shortTitle")

class Config: # noqa: D106
populate_by_name = True


class CubeJSMetaResponse(BaseModel):
"""CubeJS metadata response.

Args:
cubes: cubejs metadata entries for cubes and views.

"""

cubes: list[CubeJSMetaCube] = Field(default_factory=list)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

awesome!

Copy link
Copy Markdown
Collaborator

@rafaelleinio rafaelleinio left a comment

Choose a reason for hiding this comment

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

I'll merge and release, thanks for the contribution old friend 🤓

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a324296. Configure here.

Comment thread cubejs/model.py
@joao-victor-campos
Copy link
Copy Markdown
Contributor Author

joao-victor-campos commented May 18, 2026

I'll merge and release, thanks for the contribution old friend 🤓

haha it's been a pleasure

@rafaelleinio rafaelleinio merged commit e1fee0d into wandercom:main May 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants