Skip to content

Feat/computed attributes - #21

Merged
xvalovic merged 2 commits into
gooddata:masterfrom
xvalovic:feat/computed-attributes
Oct 16, 2026
Merged

xvalovic merged 2 commits into
gooddata:masterfrom
xvalovic:feat/computed-attributes

Conversation

@xvalovic

Copy link
Copy Markdown
Contributor

Summary

Two features for the Legacy → Cloud migration:

  1. Computed Attributes (CA). Legacy computed attributes are now migrated with the metrics step. Before this PR, any metric, insight or dashboard that used a CA failed to migrate.
  2. Creator/modifier of metrics and insights. dashboard-permissions can now set createdBy/modifiedBy on metrics and insights too, not only on dashboards.

1. Computed attributes (c5cd9c9)

Legacy CA = attr.comp.X + label.comp.X. Each one becomes a Cloud computedAttribute entity with id label.comp.X:

SELECT CASE WHEN SUM({metric/<id>}) <= 10 THEN "0-10" ... ELSE "..." END BY {label/<base>} ALL OTHER
  • Fetch and translate (metrics/computed_attribute.py, new): rel definitions are parsed with a strict grammar: one metric, numeric thresholds, literal bucket labels. A CA that does not match is logged as cannot be migrated and skipped, and the run continues.
  • Deploy order (workflows/migrate_metrics.py): plain metrics → computed attributes → metrics that reference a CA. CA creation uses the same create / --overwrite-existing semantics as other objects (ComputedAttributeCreationStrategy).
  • References. All references now use computed_attribute/… / "type": "computedAttribute" instead of label:
    • metric MAQL (content_tree_modifier.py)
    • insight attribute buckets, filters, and COUNT(attr.comp.X) measures (cloud_insight.py)
    • dashboard filter contexts (filter_context.py) and drills (drill_converter.py)
  • Id mapping. IdMappings resolves attr.comp.* / label.comp.* even without a mapping row. The metrics step also writes computed_attribute_mappings.csv.
  • Outputs: cloud_failed_computed_attributes.json and cloud_skipped_computed_attributes.json. With --dump-legacy / --dump-cloud, also legacy_computed_attributes.json and cloud_computed_attributes.json.

Requirements and limitations (also in the README)

  • Cloud CA is Beta. It needs the enableComputedAttributes feature flag on the parent and on every child workspace where the migration runs; the flag is not inherited.
  • Without the flag, GET …/computedAttributes returns 400 ("Feature 'enableComputedAttributes' is not enabled"), so the metrics step fails for that workspace, even when it has no CA content.
  • Cloud CAs do not support exports, date dimensions or period-over-period.
  • The translation wraps the metric in SUM(). This is exact for additive metrics. For metrics that are already averages (e.g. Avg Wait Time, Avg Agent Handle Time), bucket values may differ from Legacy and should be checked visually.

2. Creator/modifier of metrics and insights (e6991ec)

  • dashboard-permissions gets --include-metrics and --include-insights. Legacy author → Cloud createdBy, Legacy contributor → Cloud modifiedBy, written through the workspace layout. Metrics and insights have no permissions, so only these two fields change. The objects are read from metric_mappings.csv / insight_mappings.csv (--metric-mapping-file / --insight-mapping-file).
  • Behaviour change: dashboards now take modifiedBy from the Legacy contributor instead of author.

Testing

  • Unit tests: pytest, 119 passed. New tests:
    • tests/test_computed_attributes.py: CA translation, unsupported definitions, mappings
    • CA cases for metrics and insights (with_computed_attribute_*)
    • tests/test_layout_manager.py: createdBy / modifiedBy for metrics and insights

xvalovic and others added 2 commits October 12, 2026 14:37
Legacy computed attributes (attr.comp.X + label.comp.X) are fetched in the
metrics step, translated to Cloud computedAttribute entities
(SELECT CASE WHEN SUM({metric/..}) .. END BY {label/..} ALL OTHER) and
deployed between plain metrics and metrics that reference them.
Metrics, insights and dashboards now reference them as
{computed_attribute/label.comp.X} / type "computedAttribute".

risk: low

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
dashboard-permissions gets --include-metrics / --include-insights: Legacy
author -> Cloud createdBy and Legacy contributor -> Cloud modifiedBy are
set in the workspace layout for metrics and insights (no permissions).
Dashboards now also get modifiedBy from contributor instead of author.

risk: low

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fa16bc0a-3cf3-4990-8618-953b845a00a6
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@xvalovic
xvalovic requested a review from marmil-cz October 14, 2026 09:15

@marmil-cz marmil-cz left a comment

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.

LGTM

@xvalovic
xvalovic merged commit bc47059 into gooddata:master Oct 16, 2026
2 checks passed
@xvalovic
xvalovic deleted the feat/computed-attributes branch October 16, 2026 13:34
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.

2 participants