Skip to content

feat: Links in the data model#10852

Draft
paveltiunov wants to merge 5 commits into
masterfrom
cursor/feat-links-documentation-638d
Draft

feat: Links in the data model#10852
paveltiunov wants to merge 5 commits into
masterfrom
cursor/feat-links-documentation-638d

Conversation

@paveltiunov
Copy link
Copy Markdown
Member

@paveltiunov paveltiunov commented May 10, 2026

Check List

  • Tests have been run in packages where changes have been made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made

Implements the links feature for dimensions in the data model, as specified in #10203.

Documentation Changes

links parameter (in both docs/content/ and docs-mintlify/reference/):

  • Defines navigable URLs associated with a dimension value
  • url is a standard SQL expression (like mask.sql) — uses {CUBE}.column and {dimension} references
  • Supports label, icon, target, params, propagate_filters_to_params, param_name_for_filters
  • Only the computed URL is rendered as a SQL column; label/icon/target are metadata via /v1/meta

synthetic parameter: Documents the internal marker for auto-generated dimensions.

Context variables cross-reference: Updated FILTER_PARAMS to mention link construction.

Code Changes — JS (BaseQuery / Legacy Path)

Schema Compiler (packages/cubejs-schema-compiler):

  • CubeValidator.ts: Added links validation schema. url is Joi.func() — a SQL function evaluated through the standard pipeline, same as mask.sql
  • CubeEvaluator.ts: Added LinkDefinition type to DimensionDefinition
  • CubeToMetaTransformer.ts: Links metadata exposed via /v1/meta (label, icon, target, params config — NOT the raw sql url)
  • BaseQuery.js: When includeLinks: true, generates synthetic SQL columns using autoPrefixAndEvaluateSql(cubeName, link.url) — the exact same mechanism used for mask.sql

API Gateway (packages/cubejs-api-gateway):

  • query.ts / query.js: Added includeLinks to the Query type and validation schema
  • gateway.ts: /v1/cubesql endpoint accepts includeLinks in request body
  • sql-server.ts: Request option storage; injects includeLinks into the Cube query in the sql callback

Code Changes — Rust (Tesseract / Native SQL Planner)

cubesqlplanner crate:

  • cube_bridge/link_item.rs: New LinkItem bridge trait with url (MemberSql) and static label/icon/target
  • cube_bridge/dimension_definition.rs: Added links() method returning Vec<Rc<dyn LinkItem>>
  • cube_bridge/base_query_options.rs: Added include_links to BaseQueryOptionsStatic
  • planner/query_tools.rs: Added include_links field and getter
  • planner/base_query.rs: Passes include_links through to QueryTools
  • planner/symbols/dimension_symbol.rs: Added link_url_sqls: Vec<Rc<SqlCall>> field, compiled from link definitions in DimensionSymbolFactory::build, with getter on DimensionSymbol

Design

  • url is a standard SQL function, just like mask.sql — no custom template parsing
  • Example: url: "CONCAT('https://www.google.com/search?q=', {CUBE}.full_name)"
  • Evaluated at query time through autoPrefixAndEvaluateSql (JS) / compile_sql_call (Rust)
  • Only the URL column is computed in SQL (as <dim>___link_<id>_url); other fields (label, icon, target) are constants in /v1/meta
  • The includeLinks flag works for both /v1/load (JSON API) and /v1/cubesql (SQL-over-REST)
  • Both JS legacy and Tesseract native paths are wired
Open in Web Open in Cursor 

Add documentation for the new `links`, `html`, and `synthetic` parameters
on dimensions. Links allow defining navigable URLs associated with dimension
values, rendered as synthetic dimensions in the result set. HTML fragments
enable rich formatting beyond the `format` parameter. The `synthetic`
parameter marks auto-generated dimensions.

Also update the `meta` parameter description and add a cross-reference from
the FILTER_PARAMS context variable documentation to the new links feature.

Changes applied to both the Next.js docs (docs/content/) and the Mintlify
docs (docs-mintlify/reference/).

Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented May 10, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
cubed3 🟢 Ready View Preview May 10, 2026, 12:12 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 10, 2026

Claude finished @paveltiunov's task in 3m 3s —— View job


Review: Documentation for links, html, and synthetic dimension parameters

  • Gather context and read changed files
  • Review documentation accuracy and consistency
  • Check for issues (formatting, broken references, cross-site consistency)
  • Post review feedback

Overall this is well-written documentation — clear structure, good examples, and consistent coverage across both doc sites. A few issues to address:


Issues

1. Broken link: ref-references in Mintlify docs

In docs-mintlify/reference/data-modeling/dimensions.mdx, the reference link is:

[ref-references]: /docs/data-modeling/syntax#references

But the Mintlify syntax page lives at docs/data-modeling/concepts/syntax (per docs.json). This should be:

[ref-references]: /docs/data-modeling/concepts/syntax#references

This link is used twice in the new content (lines 438 and 480). The Next.js version (/product/data-modeling/syntax#references) is correct.

Fix this →

2. Missing trailing newline in all 4 changed files

All four files end without a trailing newline (\ No newline at end of file in the diff). This was a pre-existing issue for some files, but the PR extends it to the newly added reference link lines. POSIX convention and most linters expect a final newline.

Fix this →


Suggestions

3. Ambiguous #### Dimensions sub-headings (also left as inline comment)

The #### Dimensions heading appears under both ### links and ### html to describe the synthetic dimensions generated in the result set. Since the page itself is about dimensions, this heading reads as a circular reference. Consider something more descriptive like #### Generated dimensions or #### Synthetic dimensions in the result set. Applies to both doc sites (4 occurrences total).

4. The html example with inline Jinja-in-Jinja may confuse MDX parsers

The inline example at ~line 582 (mintlify) / ~line 448 (next.js):

html: {{ '{% if "{full_name}" | length > 10 %}...' }}

The double curly braces {{ ... }} are also MDX/JSX expression syntax. If either doc framework processes this before rendering the code fence, it could break. Worth verifying the preview renders correctly on both sites. If it doesn't, wrapping in a raw block or escaping may be needed.


Observations (non-blocking)

  • Correct component usage: Mintlify files use <Info> / <Warning> / <Note> while Next.js files use <InfoBox> / <WarningBox> / <ReferenceBox> — both are correct for their respective platforms.
  • Correct link namespacing: Reference links use /docs/... paths for Mintlify and /product/... paths for Next.js, which is the expected convention.
  • Content parity is good: The prose, examples, and structure are identical across both doc sites (modulo the expected component and path differences), which is great for maintainability.
  • meta description improvement: The rewording from "Custom metadata. Can be used to pass any information to the frontend." to "allows you to attach arbitrary information to a dimension. It can be consumed and interpreted by supporting tools." is a nice improvement. Note that the Mintlify version already had an additional ai_context paragraph that the Next.js version lacks — this is a pre-existing discrepancy, not introduced by this PR.

Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
param_name_for_filters: my_precious_filters
```

#### Dimensions
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: Ambiguous heading. The #### Dimensions heading is used as a sub-section under both links and html to describe the synthetic dimensions generated in the result set. Since this appears inside a page titled "Dimensions," the heading reads like a circular reference. Consider a more descriptive title like #### Generated dimensions or #### Synthetic dimensions in the result set to make it immediately clear what this sub-section covers.

- Add links validation schema to CubeValidator.ts (label, url, icon,
  target, params, propagate_filters_to_params, param_name_for_filters)
- Add LinkDefinition type to CubeEvaluator.ts
- Add links to DimensionConfig and ExtendedCubeSymbolDefinition types
  in CubeToMetaTransformer.ts for /v1/meta exposure
- Generate synthetic link URL columns in BaseQuery.js when includeLinks
  option is set (only url is rendered as SQL; label/icon/target are
  constant metadata exposed via /v1/meta)
- Add includeLinks flag to Query type and query validation schema
- Wire includeLinks through /v1/cubesql endpoint via request options
  stored on SQLServer, injected into the sql callback query
- Add unit tests for links feature

Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
@github-actions github-actions Bot added the javascript Pull requests that update Javascript code label May 10, 2026
The url field in links is now a SQL function (like mask.sql) that gets
evaluated through the standard evaluateSql/autoPrefixAndEvaluateSql
pipeline. This means:

- url uses standard {CUBE}.column and {dimension} references
- url supports any SQL expression (CONCAT, CASE, etc.)
- No custom template parsing is needed

The url is no longer exposed in /v1/meta (it's a server-side SQL
expression). Only constant metadata (label, icon, target, params config)
is exposed in meta. The computed URL value appears only as a SQL column
in query results when includeLinks is set.

Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
- Add include_links to BaseQueryOptionsStatic and pass it through
  BaseQuery → QueryTools
- Create LinkItem bridge (cube_bridge/link_item.rs) with url sql field
- Add links() method to DimensionDefinition bridge trait
- Compile link url SQL calls in DimensionSymbolFactory and store them
  as link_url_sqls on DimensionSymbol
- Add includeLinks to buildSqlAndParamsRust query params in BaseQuery.js

The link URL SQL expressions are compiled and stored on DimensionSymbol,
ready to be projected as additional columns when the query processor
handles include_links. The actual projection in the physical plan builder
will emit these as synthetic columns alongside their parent dimension.

Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
@github-actions github-actions Bot added the rust Pull requests that update Rust code label May 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.47%. Comparing base (e60ad99) to head (3699b35).

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #10852       +/-   ##
===========================================
+ Coverage   58.36%   83.47%   +25.11%     
===========================================
  Files         216      254       +38     
  Lines       16939    75350    +58411     
  Branches     3435        0     -3435     
===========================================
+ Hits         9887    62901    +53014     
- Misses       6550    12449     +5899     
+ Partials      502        0      -502     
Flag Coverage Δ
cube-backend ?
cubesql 83.47% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants