### Install and Run Application Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/embedding/vizard.mdx Use these commands to install dependencies and start the development server after downloading and unarchiving the generated code. Ensure the `.env.local` file is correctly placed. ```bash npm install npm run dev ``` -------------------------------- ### Example REST API Request Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/api-reference/authentication.mdx Example of how to make a GET request to the REST API for deployments, including the Authorization header. ```bash curl --request GET \ --url 'https://.cubecloud.dev/api/v1/deployments' \ --header 'Authorization: Bearer ' ``` -------------------------------- ### GET /readyz Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/core-data-apis/rest-api/reference.mdx Reports if the deployment has successfully started. It tests the connection to the default data source. ```APIDOC ## GET /readyz ### Description Reports if the deployment has successfully started by testing the connection to the default data source. ### Method GET ### Endpoint /readyz ### Response #### Success Response (200) - **health** (string) - Indicates the deployment is ready, typically "HEALTH". #### Response Example ```json { "health": "HEALTH" } ``` #### Error Response (500) - **health** (string) - Indicates the deployment is not ready, typically "DOWN". #### Response Example ```json { "health": "DOWN" } ``` ``` -------------------------------- ### Example SCIM API Request Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/api-reference/authentication.mdx Example of how to make a GET request to the SCIM API for users, including the Authorization header. ```bash curl --request GET \ --url 'https://.cubecloud.dev/api/scim/v2/Users?count=100&startIndex=1' \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Install project dependencies Source: https://github.com/cube-js/cube/blob/master/packages/cubejs-client-vue3/README.md Initializes the project by installing all required packages. ```bash yarn install ``` -------------------------------- ### Clone and Run Documentation for Specific Version Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/admin/account-billing/distribution.mdx Clone the GitHub repository for a specific version of Cube.js, navigate to the docs folder, install dependencies, and start a local documentation server. ```bash git clone --depth 1 --branch v1.5.0 https://github.com/cube-js/cube.git cd cube/docs yarn && yarn dev open http://localhost:3000 ``` -------------------------------- ### Installation Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/data-modeling/cube_dbt.mdx Instructions for installing the `cube_dbt` package. ```APIDOC ## Installation ### Cube Cloud Add the `cube_dbt` package to the `requirements.txt` file in the root directory of your Cube project. Cube Cloud will install the dependencies automatically. ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/cube-js/cube/blob/master/packages/cubejs-backend-maven/README.md Use these commands to install project dependencies and run tests. Ensure you have Yarn installed. ```bash $ yarn $ yarn test ``` -------------------------------- ### Install Prefect Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/orchestration-api/prefect.mdx Install Prefect using pip. ```bash pip install prefect-cubejs ``` -------------------------------- ### Example View Definition in YAML Source: https://github.com/cube-js/cube/blob/master/docs/content/product/data-modeling/recipes/style-guide.mdx Shows how to define a 'orders' view in YAML, specifying which cubes to include and how to alias or include specific dimensions and measures for data consumption. ```yaml views: - name: orders cubes: - join_path: base_orders includes: # dimensions - status - created_date # measures - total_amount - total_amlunt_shipped - count - average_order_value - join_path: base_orders.line_items.products includes: - name: name alias: product - join_path: base_orders.line_items.products.product_categories includes: - name: name alias: product_category - join_path: base_orders.users prefix: true includes: - city ``` -------------------------------- ### Install Cube.js React Package Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/javascript-sdk/react.mdx Install the Cube.js core client and React package using npm or Yarn. ```bash # npm npm install --save @cubejs-client/core @cubejs-client/react ``` ```bash # Yarn yarn add @cubejs-client/core @cubejs-client/react ``` -------------------------------- ### Install Cube.js CLI Source: https://github.com/cube-js/cube/blob/master/packages/cubejs-cli/README.md Installs the Cube.js CLI globally using npm. ```bash npm install -g cubejs-cli ``` -------------------------------- ### JavaScript Configuration for Tenant-Specific Data Models Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/recipes/configuration/custom-data-model-per-tenant.mdx Example JavaScript configuration using `contextToAppId`, `repositoryFactory`, and `scheduledRefreshContexts` to manage tenant-specific data models. This setup routes requests and refreshes based on tenant IDs. ```javascript const { FileRepository } = require("@cubejs-backend/server-core") module.exports = { contextToAppId: ({ securityContext }) => `CUBE_APP_${securityContext.tenant}`, repositoryFactory: ({ securityContext }) => new FileRepository(`model/${securityContext.tenant}`), scheduledRefreshContexts: () => [ { securityContext: { tenant: "avocado" } }, { securityContext: { tenant: "mango" } } ] } ``` -------------------------------- ### Example Incoming Query Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/docs/data-modeling/access-control/context.mdx This is an example of a query that might be sent to the Cube.js API. ```json { "measures": [ "orders_view.count" ], "dimensions": [ "orders_view.status" ] } ``` -------------------------------- ### Install cube_dbt via requirements.txt Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/data-modeling/cube_dbt.mdx Add the package to your requirements file to install it in your Cube project. ```bash echo "cube_dbt" > requirements.txt pip install -r requirements.txt ``` -------------------------------- ### Install Confluent CLI Source: https://github.com/cube-js/cube/blob/master/docs/content/product/configuration/data-sources/ksqldb.mdx Installs the Confluent CLI for managing ksqlDB resources. Ensure you have Homebrew installed. ```sh brew install --cask confluent-cli confluent login confluent environment use confluent ksql cluster list confluent api-key create --resource ``` -------------------------------- ### Install @cubejs-client/ngx Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/javascript-sdk/reference/cubejs-client-ngx.mdx Install the Angular module using npm or yarn. ```bash npm install --save @cubejs-client/ngx # or yarn add @cubejs-client/ngx ``` -------------------------------- ### Install React Embed SDK Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/embedding/react-embed-sdk.mdx Install the React Embed SDK using npm or yarn. ```bash npm install @cube-dev/embed-sdk # or yarn add @cube-dev/embed-sdk ``` -------------------------------- ### Start Cube.js Development Server Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/cube-core/getting-started/create-a-project.mdx Run this command in your project directory to start the Cube.js development server in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Define Orders Cube Data Model (YAML) Source: https://github.com/cube-js/cube/blob/master/docs/content/product/caching/getting-started-pre-aggregations.mdx Defines the 'orders' cube with basic measures and dimensions, including 'id', 'status', and 'completed_at'. This serves as the base for pre-aggregation examples. ```yaml cubes: - name: orders sql_table: orders measures: - name: count type: count dimensions: - name: id sql: id type: number primary_key: true - name: status sql: status type: string - name: completed_at sql: completed_at type: time ``` -------------------------------- ### Example Query for Orders Count Source: https://github.com/cube-js/cube/blob/master/docs/content/product/caching/getting-started-pre-aggregations.mdx This JSON object represents a typical query to the Cube.js API. It requests the total count of orders and specifies 'orders.completed_at' as the time dimension. This type of query can be significantly accelerated by using pre-aggregations. ```json { "measures": ["orders.count"], "timeDimensions": ["orders.completed_at"] } ``` -------------------------------- ### Start Documentation Development Server Source: https://github.com/cube-js/cube/blob/master/CLAUDE.md Starts the Mintlify development server for the active documentation site. Content is authored in `.mdx` files. ```bash cd docs-mintlify yarn dev ``` -------------------------------- ### Create a new Cube.js project Source: https://github.com/cube-js/cube/blob/master/packages/cubejs-cli/README.md Initializes a new project named hello-world with a PostgreSQL database driver. ```bash cubejs create hello-world -d postgres ``` -------------------------------- ### Start development server Source: https://github.com/cube-js/cube/blob/master/packages/cubejs-client-vue3/README.md Compiles the project and enables hot-reloading for local development. ```bash yarn run serve ``` -------------------------------- ### Complete Agent and Space Configuration Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/admin/ai/multi-agent.mdx This example demonstrates a complete configuration file, defining multiple spaces and assigning agents to them. It includes agent-specific settings like LLM and accessible views. ```yaml # agents/config.yml spaces: - name: sales-analytics description: "Space for sales team analytics and reporting" - name: marketing-analytics description: "Space for marketing team analytics" agents: - name: sales-assistant description: "AI assistant for sales analytics and reporting" space: sales-analytics llm: claude_4_6_sonnet accessible_views: - orders_view - customers_view - products_view memory_mode: user - name: marketing-analyst description: "AI assistant for marketing analytics" space: marketing-analytics llm: gpt_5 memory_mode: user ``` -------------------------------- ### Start Mintlify Dev Server Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/CLAUDE.md Navigate to the docs-mintlify directory and run this command to start the local development server for the Mintlify documentation site. ```bash cd docs-mintlify yarn dev # Start the Mintlify dev server ``` -------------------------------- ### Microsoft Entra ID SCIM Expression Mapping Example Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/docs/integrations/power-bi/kerberos.mdx Example of an expression mapping in Microsoft Entra ID SCIM provisioning to construct a user principal name from parts, useful for hybrid AD/Kerberos setups. ```text Join("@", [samAccountName], "INTERNAL.REALM") ``` -------------------------------- ### Configure Diverse Data Sources with Multiple Drivers Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/embedding/multitenancy.mdx This advanced example shows how to configure different data source types (Athena, BigQuery, PostgreSQL) based on the `dataSource` identifier. It includes specific configurations for each and a fallback for unknown sources. Ensure environment variables are correctly set for each data source. ```javascript module.exports = { driverFactory: ({ dataSource } = {}) => { if (dataSource === "web") { return { type: "athena", database: dataSource // ... } } else if (dataSource === "googleAnalytics") { return { type: "bigquery", // ... } } else if (dataSource === "financials") { return { type: "postgres", database: "financials", host: "financials-db.acme.com", user: process.env.FINANCIALS_DB_USER, password: process.env.FINANCIALS_DB_PASS } } else { return { type: "postgres", // ... } } } } ``` -------------------------------- ### HTTP Transport - Get Metadata Source: https://github.com/cube-js/cube/blob/master/docs/content/product/apis-integrations/core-data-apis/rest-api/index.mdx Example of how to retrieve metadata about the data model using the HTTP transport with curl. ```APIDOC ## GET /cubejs-api/v1/meta ### Description Retrieves metadata about the Cube.js data model, including available cubes, dimensions, and measures. ### Method GET ### Endpoint /cubejs-api/v1/meta ### Request Example ```bash curl \ -H "Authorization: TOKEN" \ http://localhost:4000/cubejs-api/v1/meta | jq ``` ### Response #### Success Response (200) - **cubes** (array) - List of available cubes. - **dimensions** (object) - Object containing dimensions grouped by cube. - **measures** (object) - Object containing measures grouped by cube. #### Response Example ```json { "cubes": [ { "name": "users" } ], "dimensions": { "users": [ { "name": "users.state" }, { "name": "users.city" } ] }, "measures": { "users": [ { "name": "users.count" } ] } } ``` ``` -------------------------------- ### Check Readiness - Successful Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/core-data-apis/rest-api/reference.mdx Use the `/readyz` endpoint to check if the deployment has successfully started. A successful response indicates that the connection to the default data source is testable. ```bash curl -i http://localhost:4000/readyz HTTP/1.1 200 OK X-Powered-By: Express Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 Content-Length: 19 ETag: W/"13-MyluqxoYxC0tUxBeZCnbaWYVLhg" Date: Mon, 18 Jan 2021 15:39:57 GMT Connection: keep-alive Keep-Alive: timeout=5 {"health":"HEALTH"} ``` -------------------------------- ### Example Data Model with Time Shift in Cube.js Source: https://github.com/cube-js/cube/blob/master/docs/content/product/data-modeling/concepts/multi-stage-calculations.mdx An example Cube.js data model demonstrating the setup of various measures, including 'revenue', 'revenue_ytd', 'revenue_prior_year', and 'revenue_prior_year_ytd'. It showcases how to define time dimensions and measures with time-shift configurations. ```yaml cubes: - name: prior_date sql: | SELECT '2023-04-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-05-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-06-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-07-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-08-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-09-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-10-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-11-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2023-12-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-01-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-02-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-03-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-04-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-05-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-06-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-07-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-08-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-09-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-10-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-11-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2024-12-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2025-01-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2025-02-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2025-03-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2025-04-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2025-05-01'::TIMESTAMP AS time, 1000 AS revenue UNION ALL SELECT '2025-06-01'::TIMESTAMP AS time, 1000 AS revenue dimensions: - name: time sql: time type: time measures: - name: revenue sql: revenue type: sum - name: revenue_ytd sql: revenue type: sum rolling_window: type: to_date granularity: year - name: revenue_prior_year multi_stage: true sql: "{revenue}" type: number time_shift: - time_dimension: time interval: 1 year type: prior - name: revenue_prior_year_ytd multi_stage: true sql: "{revenue_ytd}" type: number time_shift: - time_dimension: time interval: 1 year type: prior ``` -------------------------------- ### MDX Frontmatter Example Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/CLAUDE.md All documentation pages must start with YAML frontmatter including a 'title' and 'description'. The 'title' serves as the page's H1 heading. ```mdx --- title: Rules description: One-sentence summary used for SEO and navigation previews. --- ``` -------------------------------- ### Define Build Range for Pre-aggregations (YAML) Source: https://github.com/cube-js/cube/blob/master/docs/content/product/data-modeling/reference/pre-aggregations.mdx Sets the start and end dates for building pre-aggregation partitions using `CURRENT_DATE`. This example uses YAML syntax. ```yaml cubes: - name: orders sql_table: orders pre_aggregations: - name: main measures: - CUBE.count time_dimension: CUBE.created_at granularity: day partition_granularity: month build_range_start: sql: SELECT CURRENT_DATE - INTERVAL '300 day' build_range_end: sql: SELECT CURRENT_DATE # ... ``` -------------------------------- ### Asset Upload Examples Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/scripts/README.md Demonstrates various ways to use the `upload-asset.sh` script with different file types and destination paths. ```bash ./scripts/upload-asset.sh ./snowflake.svg icons/snowflake.svg ``` ```bash ./scripts/upload-asset.sh ./architecture.png docs/getting-started/architecture.png ``` ```bash ./scripts/upload-asset.sh ./flow.svg diagrams/pre-aggregations-flow.svg ``` -------------------------------- ### Define Build Range for Pre-aggregations (JavaScript) Source: https://github.com/cube-js/cube/blob/master/docs/content/product/data-modeling/reference/pre-aggregations.mdx Sets the start and end dates for building pre-aggregation partitions using `CURRENT_DATE`. This example uses JavaScript syntax. ```javascript cube(`orders`, { sql_table: `orders`, pre_aggregations: { main: { measures: [CUBE.count], time_dimension: CUBE.created_at, granularity: `day`, partition_granularity: `month`, build_range_start: { sql: `SELECT CURRENT_DATE - INTERVAL '300 day'` }, build_range_end: { sql: `SELECT CURRENT_DATE` } } }, // ... }) ``` -------------------------------- ### Organizing YAML Configuration Files Source: https://github.com/cube-js/cube/blob/master/docs/content/product/administration/ai/yaml-config.mdx Demonstrates how to split YAML configuration for spaces and agents across multiple files for better project organization. ```tree agents/ ├── spaces/ │ ├── sales.yml │ └── marketing.yml └── agents/ └── assistants.yml ``` -------------------------------- ### Many-to-One Join Example with Customers (YAML) Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/data-modeling/joins.mdx Illustrates a many-to-one join from 'orders' to 'customers' in YAML. This setup is common when many orders can be associated with a single customer. ```yaml cubes: - name: orders # ... joins: - name: customers relationship: many_to_one sql: "{orders}.customer_id = {customers.id}" ``` -------------------------------- ### Simple Post-processing Query: Get Version Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/core-data-apis/queries.mdx A basic example of a post-processing query that invokes a function implemented by the SQL API, executed without querying the upstream data source. ```sql SELECT VERSION(); ``` -------------------------------- ### Initialize Astro Project Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/orchestration-api/airflow.mdx Steps to create and initialize a new Astro project. Ensure Astro CLI is installed prior to running these commands. ```bash mkdir cube-astro cd cube-astro astro dev init ``` -------------------------------- ### Vue.js Query Builder Example Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/javascript-sdk/reference/cubejs-client-vue.mdx Demonstrates how to use the QueryBuilder component in a Vue.js application. It includes setup for Cube.js API, query configuration, and integration with a multiselect component for measures. ```html ``` -------------------------------- ### Define Pre-Aggregation Build Range (YAML) Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/data-modeling/pre-aggregations.mdx Configure the start and end points for building pre-aggregation partitions using SQL queries. This example sets the build range to the last 300 days. ```yaml cubes: - name: orders sql_table: orders pre_aggregations: - name: main measures: - CUBE.count time_dimension: CUBE.created_at granularity: day partition_granularity: month build_range_start: sql: SELECT CURRENT_DATE - INTERVAL '300 day' build_range_end: sql: SELECT CURRENT_DATE # ... ``` -------------------------------- ### Cube Query for Order Statuses Source: https://github.com/cube-js/cube/blob/master/docs/content/product/caching/getting-started-pre-aggregations.mdx A simple JSON query to retrieve all unique order statuses from the 'orders' cube. This demonstrates a basic query that can be optimized with pre-aggregations. ```json { "dimensions": ["orders.status"] } ``` -------------------------------- ### Configure Multiple PostgreSQL Data Sources Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/embedding/multitenancy.mdx This example demonstrates how to configure multiple PostgreSQL data sources based on the `dataSource` identifier provided in the context. Ensure all necessary environment variables for each database are set. ```javascript module.exports = { driverFactory: ({ dataSource } = {}) => { if (dataSource === "db1") { return { type: "postgres", database: process.env.DB1_NAME, host: process.env.DB1_HOST, user: process.env.DB1_USER, password: process.env.DB1_PASS, port: process.env.DB1_PORT } } else { return { type: "postgres", database: process.env.DB2_NAME, host: process.env.DB2_HOST, user: process.env.DB2_USER, password: process.env.DB2_PASS, port: process.env.DB2_PORT } } } } ``` -------------------------------- ### Start Cube.js Instance with Docker Source: https://github.com/cube-js/cube/blob/master/packages/cubejs-docker/README.md Run a Cube.js instance using the official Docker image. Ensure all required database and API secret environment variables are set. Mount a local directory for configuration files. ```bash docker pull cubejs/cube:latest docker run -d -p 3000:3000 -p 4000:4000 \ -e CUBEJS_DB_HOST=postgres://hostname \ -e CUBEJS_DB_NAME= \ -e CUBEJS_DB_USER= \ -e CUBEJS_DB_PASS= \ -e CUBEJS_DB_TYPE= \ -e CUBEJS_API_SECRET= \ -v $(pwd):/cube/conf \ cubejs/cube:latest ``` -------------------------------- ### Expose dbt Models and Columns as Jinja Functions Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/recipes/data-modeling/dbt.mdx Set up Jinja template functions to access dbt models and individual models by name. This is typically done once at the start of your template context setup. ```python from cube import TemplateContext from cube_dbt import Dbt manifest_url = 'https://cube-dbt-integration.s3.amazonaws.com/manifest.json' dbt = Dbt.from_url(manifest_url).filter(paths=['marts/']) template = TemplateContext() @template.function('dbt_models') def dbt_models(): return dbt.models @template.function('dbt_model') def dbt_model(name): return dbt.model(name) ``` -------------------------------- ### Define Pre-Aggregation Build Range (JavaScript) Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/data-modeling/pre-aggregations.mdx Configure the start and end points for building pre-aggregation partitions using SQL queries in JavaScript. This example sets the build range to the last 300 days. ```javascript cube(`orders`, { sql_table: `orders`, pre_aggregations: { main: { measures: [CUBE.count], time_dimension: CUBE.created_at, granularity: `day`, partition_granularity: `month`, build_range_start: { sql: `SELECT CURRENT_DATE - INTERVAL '300 day'` }, build_range_end: { sql: `SELECT CURRENT_DATE` } } }, // ... }) ``` -------------------------------- ### Run Cube with Docker and Connect to Cube Store Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/cube-core/running-in-production.mdx Starts a Cube instance using the official Docker image and configures it to connect to a Cube Store instance running on localhost:3030. Mounts local configuration to the container. ```bash docker run -p 4000:4000 \ -e CUBEJS_CUBESTORE_HOST=localhost \ -v ${PWD}:/cube/conf \ cubejs/cube ``` -------------------------------- ### Example Cube Definition in YAML Source: https://github.com/cube-js/cube/blob/master/docs/content/product/data-modeling/recipes/style-guide.mdx Demonstrates the structure and parameters for defining a 'line_items' cube in YAML. It includes join relationships, dimensions, and measures, adhering to the specified parameter ordering. ```yaml cubes: - name: line_items sql_table: public.line_items public: false joins: - name: products sql: "{CUBE}.product_id = {products.id}" relationship: many_to_one - name: orders sql: "{CUBE}.order_id = {orders.id}" relationship: many_to_one dimensions: - name: id sql: id type: number primary_key: true - name: created_date sql: created_at type: time measures: - name: count type: count - name: total_amount sql: price type: sum ``` -------------------------------- ### Folder Structure Example Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/docs/data-modeling/concepts/syntax.mdx Illustrates the recommended directory layout for data model files, separating cubes and views into distinct subfolders. ```tree model ├── cubes │ ├── orders.yml │ ├── products.yml │ └── users.yml └── views ├── revenue.yml └── view_groups.yml ``` -------------------------------- ### Run Cube Store with Docker Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/cube-core/running-in-production.mdx Starts a Cube Store instance using the official Docker image. Ensure Cube Store is running as a separate process in production. ```bash docker run -p 3030:3030 cubejs/cubestore ``` -------------------------------- ### Configure Prometheus Exporter for Metrics Source: https://github.com/cube-js/cube/blob/master/docs/content/product/administration/deployment/monitoring/index.mdx Example TOML configuration for using the native Prometheus exporter sink. This setup allows Prometheus to scrape metrics directly from the Cube server. ```toml [sinks.prometheus] type = "prometheus_exporter" inputs = [ "metrics" ] [sinks.prometheus.metrics] list = [ "cpu", "memory", "requests-count", "requests-errors-count", "requests-success-count", "requests-duration" ] inputs = [ "cubejs-server" ] ``` -------------------------------- ### Define Pre-aggregation for Order Statuses (JavaScript) Source: https://github.com/cube-js/cube/blob/master/docs/content/product/caching/getting-started-pre-aggregations.mdx Defines a pre-aggregation named 'order_statuses' using the Cube.js JavaScript API, specifying the 'status' dimension. This optimizes queries that require only the status field. ```javascript cube(`orders`, { // ... pre_aggregations: { order_statuses: { dimensions: [status] } } }) ``` -------------------------------- ### `Dbt` Class Initialization Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/reference/data-modeling/cube_dbt.mdx Demonstrates how to initialize the `Dbt` class by loading dbt project metadata from a `manifest.json` file. ```APIDOC ## `Dbt` class Encapsulates tools for working with the metadata of a dbt project. ### `Dbt.__init__` The constructor accepts the metadata of a dbt project as a `dict` with the contents of a [`manifest.json` file][link-dbt-manifest]. ```python import json from cube_dbt import Dbt manifest_path = './manifest.json' with open(manifest_path, 'r') as file: manifest = json.loads(file.read()) dbt = Dbt(manifest) ``` Use in cases when `Dbt.from_file` and `Dbt.from_url` aren't applicable, e.g., when `manifest.json` is loaded from a private AWS S3 bucket. ``` -------------------------------- ### Create Dockerfile and .dockerignore Source: https://github.com/cube-js/cube/blob/master/docs-mintlify/admin/deployment/core.mdx Create a `Dockerfile` and a `.dockerignore` file to prepare for building a custom Cube.js Docker image with additional dependencies. ```bash touch Dockerfile touch .dockerignore ```