[pull] master from cube-js:master#443
Merged
pull[bot] merged 1 commit intocode:masterfrom May 2, 2026
Merged
Conversation
* feat: add view_group support to data model
Add view_group as a new first-class object in the Cube data model.
View groups can be defined either as standalone view_group() objects
or via the viewGroup property on individual views.
- Add ViewGroupEvaluator compiler
- Add view_group() global function in DataSchemaCompiler
- Add viewGroup property to view schema in CubeValidator
- Handle view_groups in YamlCompiler for YAML data models
- Resolve and merge view groups in CubeToMetaTransformer
- Include viewGroups in meta API response
- Add comprehensive tests for both JS and YAML definitions
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* fix: address lint errors and fix metaConfig consumers
- Fix no-continue lint errors in CubeToMetaTransformer
- Remove unused CompiledViewGroup import
- Fix prefer-const lint errors in gateway
- Update all metaConfig consumers to handle new object format
- Fix metaTransformer.compileViewGroups() timing via DataSchemaCompiler
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* test: add comprehensive YAML view_group tests
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* test: add E2E smoke test for view_group in meta endpoint
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* feat: support plural viewGroups property on views
A view can now belong to multiple view groups via the viewGroups
(plural) array property, in addition to the existing singular
viewGroup property. Both can be combined and are merged.
The meta response includes both viewGroup (singular, set when only
one group) and viewGroups (plural array, always set when groups
exist) on view configs.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* test: add cubejs-testing smoke test for view groups
Add smoke-view-groups.test.ts that spins up a DuckDB birdbox with
view_group definitions and verifies the /v1/meta response includes
viewGroups data. Tests cover standalone view_group definitions,
view-level viewGroup property, plural viewGroups property, and
that views in groups can be queried normally.
Also add ViewGroup type and viewGroup/viewGroups fields to
cubejs-client-core MetaResponse/Cube types.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* refactor: make view groups opt-in via includeViewGroups flag
Avoid breaking the CompilerApi.metaConfig() return type.
By default metaConfig() still returns a plain cubes array,
preserving backward compatibility for all existing consumers
(GraphQL, load, sqlApiLoad, Rust/native bridge).
viewGroups are only included when includeViewGroups: true is
passed, which the gateway meta() handler does. This ensures
the /v1/meta HTTP response includes viewGroups while all
internal callers remain unaffected.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* fix: address code review feedback
- Filter viewGroups by visible cubes in meta response to prevent
RBAC/access policy leak of restricted view names
- Validate view names in view_group definitions against actual views,
silently dropping references to non-existent views
- Remove unused viewGroupForView() method from ViewGroupEvaluator
- Only call compileViewGroups() in phase 3 (when viewGroupCompilers
are present), avoiding wasted work in phases 0-2
- Improve ViewGroupInput.views type from any to string[] | (() => string[])
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* perf: use Map lookups instead of Array.find in resolveViewGroups
Replace O(n²) Array.find() scans with O(1) Map lookups for both
cubeDefByName and transformedByName in resolveViewGroups().
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* refactor: remove singular viewGroup from meta output, use only viewGroups array
In the meta response, views now only have a viewGroups (plural)
array field. The singular viewGroup field is removed from meta
output. The singular viewGroup property on view definitions is
still accepted as input — it gets resolved into the viewGroups
array in the response.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* refactor: move view group resolution logic into ViewGroupEvaluator
ViewGroupEvaluator now owns all resolution logic: it takes
CubeEvaluator as a dependency, merges standalone view_group()
definitions with view-level viewGroup/viewGroups properties,
validates view names, and produces the final CompiledViewGroup[].
CubeToMetaTransformer is simplified to just read resolved view
groups from ViewGroupEvaluator and populate the viewGroups field
on view cube configs via lazy evaluation.
Removed the metaTransformer reference from DataSchemaCompiler
and the ViewGroupConfig type from CubeToMetaTransformer (reuses
CompiledViewGroup from ViewGroupEvaluator).
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* feat: support transpiled view references in view_group definitions
view_group() now accepts both string references and transpiled
bare identifier references for the views field, following the
same pattern as contextMembers in context() and member references
in pre-aggregations.
JS: view_group("sales", { views: [revenue, customers] })
JS: view_group("sales", { views: ["revenue", "customers"] })
YAML: views: [revenue, customers]
The transpiler handles view_group() calls the same way as
context() calls. ViewGroupEvaluator uses evaluateReferences()
to resolve transpiled references during compilation.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* fix: keep view-level viewGroup/viewGroups as plain strings
View group names on views (viewGroup/viewGroups) are plain string
identifiers, not cube/view references. They cannot be transpiled
as bare identifier references because view group names are not
registered in the cube symbol table.
Only the views field in standalone view_group() definitions
supports both string and transpiled references, since those
reference actual view names which ARE in the symbol table.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* fix: keep cubes as a public field, not _cubes
Restore cubes as a plain public field on CubeToMetaTransformer.
The viewGroups getter triggers lazy population of viewGroups on
cube configs. Tests access metaTransformer.viewGroups before
checking cube config.viewGroups to ensure population.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* fix: fail compilation when view references non-existent view group
Views that reference a view group via viewGroup or viewGroups
must reference a group that has been defined with view_group().
Referencing an undefined group now produces a compile error.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* ci: add smoke:view-groups to CI smoke test suite
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* refactor: use Map for viewGroupsForView and add viewGroups during transform
- ViewGroupEvaluator builds a viewToGroups Map during resolve()
for O(1) lookup in viewGroupsForView()
- CubeToMetaTransformer adds viewGroups to cube config directly
in transform() instead of lazy evaluation
- metaTransformer moved to new metaCompilers phase that runs
after viewGroupCompilers, ensuring view group data is available
during transformation
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
* feat: support bare identifier references for viewGroup/viewGroups on views
view_group() now returns the group name string and registers it
as a global in the V8 context, so it can be used as a bare
identifier reference on views:
view_group("sales", { title: "Sales", views: [revenue] });
view("revenue", {
viewGroup: sales, // bare reference to the view group
cubes: [{ joinPath: Orders, includes: "*" }]
});
viewGroup/viewGroups on views are now transpiled fields that
accept both string literals and transpiled references. The
ViewGroupEvaluator evaluates function references during
resolution.
Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )