Skip to content

feat(cubejs): exempt configured partitions from query rewrite row rules - #96

Merged
acmeguy merged 1 commit into
mainfrom
feat/row-rules-exempt-partitions
Oct 12, 2026
Merged

acmeguy merged 1 commit into
mainfrom
feat/row-rules-exempt-partitions

Conversation

@acmeguy

@acmeguy acmeguy commented Oct 12, 2026

Copy link
Copy Markdown

Why

The platform owner's team (partition fftech.is) must be able to read every partition. The query rewrite row rules (query_rewrite_rules: semantic_events, data_points and entities, each partition equals team.settings.partition) scope every team to its own partition.

Change

services/cubejs/src/utils/queryRewrite.js only (owner decision):

  • CUBEJS_ROW_RULES_EXEMPT_PARTITIONS: a comma-separated list of partitions, trimmed. Read once at module load.
  • Step 1 (rule-based row filtering) is skipped when teamProperties.partition is in the list. Partition pruning (step 0b) and the field-level access list (step 2) are unchanged.
  • Unset or empty means no exemptions, so behaviour is identical to before.

The value comes from deployment config. Tenants cannot exempt themselves: Hasura lets team owners update only name, and settings is written by provisioning with the admin secret.

Not changed: profileTable, smartGenerate and runSql still apply the rules to every team, fftech.is included.

Verification (local stack, real API, one user: fftech.is member + bonus.is admin, no access lists)

fftech.is datasource bonus.is datasource
env unset, before the change (/dry-run) partition equals fftech.is partition equals bonus.is
env " fftech.is , example.test" (/dry-run) no filter partition equals bonus.is
same env, /load grouped by partition 8 partitions (fftech.is, contextsuite.com, bonus.is, blue.is, …) bonus.is only
env unset, with the change (/dry-run) partition equals fftech.is partition equals bonus.is

npm test in services/cubejs: 703 pass, 2 fail, identical with and without this change. Both failures are runtimeDependencyHardening.test.js checking installed package versions (thrift 0.20.0 found vs 0.23.0 in the lockfile) and come from my local node_modules. The image installs with Yarn 1 from the lockfile.

🤖 Generated with Claude Code

The platform owner's team (partition fftech.is) must see every partition,
but the rule-based row filters scope every team to its own
settings.partition. CUBEJS_ROW_RULES_EXEMPT_PARTITIONS (comma-separated)
lists partitions whose teams skip Step 1 of queryRewrite. Partition pruning
and the field-level access list still apply. The value is deployment
config, and teams cannot write settings through Hasura (owners may update
only `name`), so a tenant cannot exempt itself.

Scope is queryRewrite only, by owner decision; profileTable, smartGenerate
and runSql keep applying the rules.

Verified on the local stack through /api/v1/dry-run and /api/v1/load as one
user who is a member of fftech.is and admin of bonus.is: with the variable
set, fftech.is gets no partition filter and reads eight partitions while
bonus.is stays filtered to bonus.is; unset, both are filtered as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acmeguy
acmeguy merged commit 02a7c98 into main Oct 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant