Data modeling
Testing your models

Using the Data Playground

You can test your models in Embeddable’s Data Playground. Simply click the in-platform Data Playground tab on the left of the main platform screen:

  • View as: this allows you to test the row-level security by viewing the data as if you are different end-users (learn more).
  • Data model: choose which data model you want to test (defining data models)
  • Columns: choose which dimensions and measures you want to see (note that all dimensions and measures that are "reachable" from the chosen data model will be available here. i.e. any dimensions and measures from any model that can be reached via a join) (dimensions and measures)
  • Models version: this allows you to load previous versions of models (pushing your models)
  • Generated SQL: once you click the "Run" button, the SQL that will be used to retrieve your chosen columns will be shown here. This is very useful for debugging your models to understand if the SQL has been defined correctly for your database data.
  • Results: once you click the "Run" button, the SQL will be run against your database, and the results will be shown here (or an error message if your database has a problem running the generated SQL).

Testing your local data models

The data playground (see above) can also be used to test code models locally on your computer. Access it by running:

npm run embeddable:dev

from your code repository. This will spin up a "dev" workspace that uses your local models.

  • The local workspace uses the same data connections as your online workspace.
  • Simply click the Data Playground tab in the left sidebar.
  • You’ll then be able to test each element of your models, view the generated SQL, and inspect the results.

You can also build dashboards in the "dev" workspace to test your local models on a dashboard.

💡

If your models are in a separate repo to your components then, when running embeddable:dev, you'll have access to the components available in your online workspace.

Testing using Cube's Data Playground

You can also use Cube's local Data Playground to test and debug your models.

This relies on you having Docker (opens in a new tab) installed on your local machine.

Create a .env file:

Ensure your .env file is in the same directory as cube-playground.yml (this directory (opens in a new tab)).

Populate the .env file:

Populate the .env file with the correct database credentials for your database as per the Cube's documentation (opens in a new tab).

CUBEJS_DB_TYPE=postgres
CUBEJS_DB_HOST=localhost
CUBEJS_DB_NAME=your_database
CUBEJS_DB_USER=your_username
CUBEJS_DB_PASS=your_password

You may need to add:

CUBEJS_DB_SSL=true

You can also add set the desired level of logging detail, which can be useful for debugging and monitoring:

CUBEJS_DB_SSL=warn 

Possible values:
warn (default value): Logs warnings in addition to errors.
Example: Deprecation warnings or configuration issues.

error: Logs only critical errors that affect the application's functionality.
Example: Database connection issues or critical service failures.

info: Logs general informational messages about the application's operations.
Example: Application startup, health checks, or key lifecycle events.

trace: Logs the most detailed information, primarily used for in-depth debugging.
Example: Internal function calls and exhaustive execution details.

Run the Playground

Execute the following command to start Cube's data playground:

npm run cube:playground

You can also use docker compose:

docker compose -f ./src/cube-playground.yml up

Access the Playground

Open your browser and navigate to localhost:4000 (opens in a new tab) to use Cube Playground.

Still Need Help?

If you encounter any issues while testing your data models, feel free to reach out to our Slack community (opens in a new tab) or contact our support team for assistance.