Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

feat: record ranking/measure-value filter dimensions in visualizations_references - #48

Merged
vondravl merged 1 commit into
mainfrom
feature/ranking-dimension-refs
Aug 25, 2026
Merged

vondravl merged 1 commit into
mainfrom
feature/ranking-dimension-refs

Conversation

@vondravl

Copy link
Copy Markdown
Owner

Problem

process_visualizations_references recorded the measure a rankingFilter/measureValueFilter ranks by, but never the dimension it ranks over. That dimension appeared in no table at all — visualizations_filters stores the operator, N and strictness, but leaves display_form_id empty.

A ranking dimension carries the same join-reachability requirement as an axis attribute: one the measure's fact cannot reach fails the visualization outright.

400 Bad Request
"Aggregation dimension='[attribute/auth_response_name]'
 is not comparable to the dimensionality='[dataset/fact_bmk_me]'
 of the subtree"

Because nothing recorded it, v_objects_not_comparable could not see it. A consuming workspace shipped 8 insights in exactly this state — a benchmark dimension ranked by a non-benchmark label, and one the other way round — behind a green check.

Changes

Extraction — both spellings are read (attributes in stored insight content, dimensionality in the AFM API; both occur in the wild) and both entry shapes:

  • a direct identifier emits a row with local_identifier NULL, keeping the payload's type verbatim — an AfmObjectIdentifier here is legally a label or an attribute;
  • a bucket handle resolves like any other localIdentifier target, so the table answers "what does this filter rank over?" as it already does for sorts.

Handles resolve against attribute-only lookups. Validating them against the shared bucket maps (which also hold measures) would let a dimension naming a measure handle be recorded as a valid metric reference instead of flagged.

Validity — a dangling dimension handle gets its own object_type ({filter}_dimension_invalid), distinct from the {filter}_invalid of a missing measure handle, since both break rendering but the fixes differ. Wired into visualizations_is_valid and v_visualizations_invalid_filters, which gains an invalid_target column.

v_objects_not_comparable — three corrections, each guarding a distinct failure:

  1. Sources widened, and object_type = 'label' alone relaxed — it would have dropped every attribute-typed dimension, half the shape this exists to catch.
  2. Dimension rows scope to the measure their filter names. An axis attribute applies to the whole result and correctly pairs with every measure; a ranking dimension does not — AFM raises the incomparability for that subtree alone. Pairing it with every measure manufactured a violation for any sibling measure that legitimately never touches the dimension, the same false-positive class the "none reach" rule was chosen to avoid. Resolution goes through visualizations_filters, and only when the visualization has exactly one filter of that type; an ambiguous handle drops the row, erring toward a false negative as this view does elsewhere.
  3. No double-reporting. Ranking rows are admitted only in their direct-identifier form, and suppressed even then when an axis or filter slice already resolves to the same owning attribute. The axis row wins — it is the broader claim.

De-duplication lives in the view rather than the extractor on purpose: dropping a real reference to suit one consumer would cost every other consumer the inventory.

Behaviour change

A visualization whose ranking filter names a missing dimension handle now flips is_valid to 0 in local mode, where it previously stayed 1. Called out under ### Changed in the CHANGELOG.

Verification

  • 255 tests pass, ruff clean. +12 new: 7 extractor cases (both spellings, both shapes, attribute-typed identifier, measure-handle-as-dimension, dangling handle, measureValueFilter) and a new tests/test_objects_not_comparable_view.py running the real view SQL on an in-memory fixture — covering measure scoping, the Revenue/Cost sibling case, both duplication paths, and the ambiguous-filter drop.
  • End-to-end in a consuming repo: pre-fix YAML → all 8 insights flagged offline, no token, no network; post-fix → 0. Six sibling data products → 0 violations, so the change adds no false positives.
  • Each of the 8 was independently confirmed against a live workspace, and the reported 400 reproduced exactly from the pre-fix payload.

🤖 Generated with Claude Code

…s_references

The extractor read only the measure a rankingFilter/measureValueFilter ranks
*by*, never the dimension it ranks *over*. That dimension appeared in no table:
visualizations_filters keeps the operator, N and strictness but leaves
display_form_id empty. So a dimension unreachable from the measure's fact — which
fails the visualization outright ("Aggregation dimension ... is not comparable to
the dimensionality ... of the subtree") — was invisible to every offline check.

Accepts both spellings (`attributes` in stored content, `dimensionality` in AFM)
and both entry shapes: a bucket handle resolves like any other localIdentifier
target, incl. the {source}_invalid dangling flag; a direct label emits a row with
local_identifier NULL. The direct-label form is the one nothing else recorded.

v_objects_not_comparable's slice CTE is widened to match. The existing
object_type = 'label' predicate admits only dimensions, keeping the filters'
measure rows (metric) and dangling handles ({source}_invalid) out.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vondravl
vondravl marked this pull request as ready for review August 25, 2026 13:25
@vondravl
vondravl merged commit 187bf7a into main Aug 25, 2026
1 check passed
@vondravl
vondravl deleted the feature/ranking-dimension-refs branch August 25, 2026 13:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant