Accessing Cube Playground
Prerequisites
Before accessing Cube Playground:- Select a project - Choose an active Cube project
- Select a branch - Choose a branch to work with
Cube Playground interface
Main components
The Cube Playground interface includes: Query builder- Visual drag-and-drop interface for building queries
- Select measures and dimensions from available cubes
- Apply filters and configure aggregations
- Preview query results
- Direct SQL query execution
- Syntax highlighting and autocomplete
- Query history and saved queries
- Execute and test queries
- Browse available cubes, measures, and dimensions
- View cube definitions and metadata
- Understand data structure and relationships
- Navigate hierarchical cube organization
- Display query results in tables or charts
- Export results to various formats
- Analyze data patterns and insights
- Edit cube definitions using YAML or JavaScript
- Version-controlled schema files
- Deploy and test schema changes
Building queries
Visual query builder
Use the visual query builder to create queries without writing SQL:-
Select cube
- Choose a cube from the sidebar
- View available measures and dimensions
-
Choose measures
- Select quantitative metrics to calculate
- Examples: revenue, orders, users, conversions
- Can select multiple measures
-
Add dimensions
- Select attributes for grouping and analysis
- Examples: date, region, product category
- Can add multiple dimensions
-
Apply filters
- Filter data by specific values or ranges
- Date range filters
- Categorical filters
- Numeric filters
-
Configure aggregations
- Set time granularity (day, week, month, etc.)
- Configure sorting and ordering
- Set result limits
-
Execute query
- Click “Run” to execute the query
- View results in the results panel
- Export or save query if needed
SQL editor
Write SQL queries directly for advanced use cases:-
Open SQL editor
- Switch to SQL editor tab
- Write SQL queries using Cube.js SQL syntax
-
Query syntax
-
Execute and test
- Click “Run” to execute
- Review results and query performance
- Iterate and refine queries
-
Save queries
- Save frequently used queries
- Share queries with team members
- Build query library
Defining cubes
Cube schema structure
Cubes are defined using YAML or JavaScript schema files:Schema components
Measures- Quantitative metrics and calculations
- Types: count, sum, avg, min, max, number
- Custom SQL expressions
- Aggregation functions
- Attributes for analysis and grouping
- Types: string, number, time, boolean
- Primary keys for joins
- Hierarchical relationships
- Special dimensions for time-based analysis
- Support for time grains (day, week, month, etc.)
- Built-in time intelligence functions
- Period-over-period comparisons
Editing schemas
-
Access schema files
- Navigate to schema files in Cube Playground
- Edit YAML or JavaScript files directly
-
Make changes
- Add new cubes, measures, or dimensions
- Modify existing definitions
- Update SQL expressions
-
Save and deploy
- Save schema changes
- Deploy to make changes available
- Changes take effect immediately
-
Test changes
- Test queries in Playground
- Verify results are correct
- Iterate and refine
Exploring data
Schema explorer
Browse your cube structure:-
View cubes
- See all available cubes in sidebar
- Navigate cube hierarchy
- Understand cube relationships
-
Explore measures
- View available measures per cube
- Understand measure definitions
- See measure types and calculations
-
Explore dimensions
- View available dimensions per cube
- Understand dimension types
- See dimension relationships
Data preview
Preview actual data:-
Sample data
- View sample data from cubes
- Understand data structure
- Verify data quality
-
Query results
- Execute queries and view results
- Analyze data patterns
- Export results for further analysis
Best practices
Query building
Start simple
Build incrementallyStart with basic queries and add complexity gradually. Test each step before adding more measures or dimensions.
Use filters
Limit data scopeApply filters to reduce data volume and improve query performance. Filter early in your query building process.
Test in Playground
Validate before deployingAlways test queries in Cube Playground before using them in production dashboards or applications.
Document queries
Add commentsDocument complex queries with comments explaining business logic and calculations.
Schema development
- Version control - Commit schema changes regularly with descriptive messages
- Incremental changes - Make small, testable changes rather than large refactors
- Documentation - Add descriptions and examples to cube definitions
- Testing - Test schema changes thoroughly before deploying
- Review - Use pull requests for schema changes in protected branches
Performance optimization
- Efficient measures - Use appropriate aggregation types
- Indexed dimensions - Ensure frequently used dimensions are indexed
- Query optimization - Review query performance and optimize slow queries
- Data filtering - Apply filters to reduce data volume
- Caching - Leverage Cube.js caching for frequently accessed data
Troubleshooting
Common issues
Playground not loading
Playground not loading
Possible causes:
- Heartbeat status not RUNNING
- Project not selected
- Branch not selected
- Network connectivity issues
- Check heartbeat status indicator
- Verify project and branch are selected
- Wait for server to start (check deployment options)
- Refresh the page
- Check browser console for errors
Query errors
Query errors
Possible causes:
- Invalid cube or measure names
- SQL syntax errors
- Missing dimensions or filters
- Data source connection issues
- Verify cube and measure names are correct
- Check SQL syntax
- Ensure required dimensions are included
- Verify data source connection
- Review error messages for specific issues
Slow query performance
Slow query performance
Possible causes:
- Large data volumes
- Inefficient queries
- Missing indexes
- Complex calculations
- Apply filters to reduce data volume
- Optimize query structure
- Check database indexes
- Simplify complex calculations
- Use pre-aggregations where possible