Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# A Sigma workbook's latest version is a number dashboard custom property

- **Status:** Accepted
- **Revisions:** v1 2026-11-07 (initial)
- **Deciders:** Sigma connector maintainers (PR #37300)
- **Guard:** `ingestion/tests/unit/topology/dashboard/test_sigma.py`
(`test_the_workbook_version_is_patched_onto_its_dashboard`,
`test_a_latest_version_property_of_another_type_is_left_alone`,
`test_no_workbook_version_is_set_without_custom_properties`,
`test_a_failed_registration_sets_no_version_and_is_not_retried`, `test_a_registered_latest_version_property_is_reused`)
- **Related:** ADR:2026-11-02-run-changing-dashboard-custom-properties-are-patched-after-the-dashboard, PR #37300

## Context

A Sigma workbook's `latestVersion` is its most recently published version, and it changes each time the workbook is
republished. The spec types it as `number` (`double`). A value that changes between runs is patched after the
dashboard, behind `includeCustomProperties`
(ADR:2026-11-02-run-changing-dashboard-custom-properties-are-patched-after-the-dashboard). A custom property definition
applies to every dashboard in the instance, whatever its service, so its name and type are shared with every
connector.

## Decision

- Sigma registers one dashboard custom property, `latestVersion`, of type `number`, because the spec types the value
as a double. Once per run, when the first workbook with a version is patched, Sigma looks the property up and
registers it if it is missing.
- An existing `latestVersion` property of type `number` is reused. One of another type is left alone: Sigma sets no
value, and the run logs a warning.
- A failed registration sets no value for the rest of the run and is not retried in that run.

## Consequences

- The name and the type are a contract. Renaming or retyping the property orphans the values stored under the old
definition.
- The name is generic. A `latestVersion` property that another connector or a user registered with another type turns
Sigma's value off until it is removed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
from metadata.entity_resolution.table_binding import TableLookup, UnsupportedTableReferenceError
from metadata.entity_resolution.table_search import get_table_binding_resolution
from metadata.generated.schema.api.data.createChart import CreateChartRequest
from metadata.generated.schema.api.data.createCustomProperty import (
CreateCustomPropertyRequest,
)
from metadata.generated.schema.api.data.createDashboard import CreateDashboardRequest
from metadata.generated.schema.api.data.createDashboardDataModel import (
CreateDashboardDataModelRequest,
)
from metadata.generated.schema.entity.data.chart import Chart
from metadata.generated.schema.entity.data.dashboard import Dashboard
from metadata.generated.schema.entity.data.dashboardDataModel import (
DashboardDataModel,
DataModelType,
Expand All @@ -42,6 +46,7 @@
Source as WorkflowSource,
)
from metadata.generated.schema.type.basic import (
EntityExtension,
EntityName,
FullyQualifiedEntityName,
Markdown,
Expand All @@ -55,7 +60,12 @@
from metadata.ingestion.api.steps import InvalidSourceException
from metadata.ingestion.lineage.models import ConnectionTypeDialectMapper, Dialect
from metadata.ingestion.lineage.parser import LineageParser
from metadata.ingestion.models.custom_properties import (
CustomPropertyDataTypes,
OMetaCustomProperties,
)
from metadata.ingestion.models.ometa_lineage import OMetaLineageRequest
from metadata.ingestion.models.patch_request import PatchRequest
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.ingestion.ometa.utils import model_str
from metadata.ingestion.source.dashboard.dashboard_service import DashboardServiceSource
Expand Down Expand Up @@ -100,6 +110,12 @@ def _access_details(moment: datetime | None) -> AccessDetails | None:
return AccessDetails(timestamp=Timestamp(datetime_to_timestamp(moment, milliseconds=True))) if moment else None


# Dashboard custom property set from the workbook (ADR:2026-11-02-run-changing-dashboard-custom-properties-are-patched-after-the-dashboard).
# The spec types it number(double), so it is not registered as an integer
# (ADR:2026-11-07-sigma-latest-version-is-a-number-dashboard-custom-property).
LATEST_VERSION = "latestVersion"
Comment thread
gitar-bot[bot] marked this conversation as resolved.
Resolved


class SigmaSource(DashboardServiceSource):
"""
Sigma Source Class
Expand Down Expand Up @@ -549,6 +565,85 @@ def yield_dashboard_lineage(self, dashboard_details: WorkbookDetails) -> Iterabl
self._get_add_lineage_request(to_entity=to_entity, from_entity=from_entity)
)

def yield_dashboard_extension(self, dashboard_details: WorkbookDetails) -> Iterable[Either[PatchRequest]]:
"""The workbook's latest published version, which changes each time the workbook is published"""
if not (
dashboard_details
and self.source_config.includeCustomProperties
and dashboard_details.latestVersion is not None
):
return
try:
if not self._latest_version_defined:
return
Comment thread
gitar-bot[bot] marked this conversation as resolved.
Resolved
dashboard = self.metadata.get_by_name(
entity=Dashboard,
fqn=fqn._build(vars(self.context.get())["dashboard_service"], dashboard_details.workbookId),
fields=["extension"],
)
if not dashboard:
return
stored = dashboard.extension.root if dashboard.extension else {}
# The properties a user set on the dashboard are sent back as they are, so the patch only touches this one
yield Either(
left=None,
right=PatchRequest(
original_entity=dashboard,
new_entity=dashboard.model_copy(
update={
"extension": EntityExtension({**stored, LATEST_VERSION: dashboard_details.latestVersion})
}
),
override_metadata=True,
),
)
except Exception as exc:
yield Either(
left=StackTraceError(
name=f"{dashboard_details.name} Custom Properties",
error=f"Error setting the latest version of Sigma workbook {dashboard_details.workbookId}: {exc}",
stackTrace=traceback.format_exc(),
),
right=None,
)

@cached_property
def _latest_version_defined(self) -> bool:
"""
Whether dashboards hold LATEST_VERSION as a number, registering it once per run. A property of that name
with another type is left alone: changing its type would invalidate the value every dashboard holds.
"""
defined = {
prop.get("name"): (prop.get("propertyType") or {}).get("name")
for prop in self.metadata.get_entity_custom_properties(entity_type=Dashboard) or []
}
if LATEST_VERSION in defined:
if defined[LATEST_VERSION] == CustomPropertyDataTypes.NUMBER.value:
return True
logger.warning(
"Dashboard custom property %s exists as %s, not %s; Sigma won't set it",
LATEST_VERSION,
defined[LATEST_VERSION],
CustomPropertyDataTypes.NUMBER.value,
)
return False
try:
self.metadata.create_or_update_custom_property(
OMetaCustomProperties(
entity_type=Dashboard,
createCustomPropertyRequest=CreateCustomPropertyRequest(
name=EntityName(LATEST_VERSION),
description=Markdown("The most recently published version of the Sigma workbook"),
propertyType=self.metadata.get_property_type_ref(CustomPropertyDataTypes.NUMBER),
),
)
)
except Exception as exc:
logger.debug(traceback.format_exc())
logger.warning("Could not register dashboard custom property %s: %s", LATEST_VERSION, exc)
return False
return True

def get_column_info(self, element: Elements) -> list[Column] | None:
"""Build data model columns"""
datamodel_columns = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class WorkbookDetails(BaseModel):
updatedAt: datetime | None = None # noqa: N815
url: str
path: str | None = None
latestVersion: int | float | None = None # noqa: N815
ownerId: str | None = None # noqa: N815
isArchived: bool | None = None # noqa: N815
description: str | None = None
Expand Down
132 changes: 131 additions & 1 deletion ingestion/tests/unit/topology/dashboard/test_sigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,18 @@
from metadata.generated.schema.metadataIngestion.workflow import (
OpenMetadataWorkflowConfig,
)
from metadata.generated.schema.type.basic import FullyQualifiedEntityName
from metadata.generated.schema.type.basic import EntityExtension, FullyQualifiedEntityName
from metadata.generated.schema.type.customProperty import PropertyType
from metadata.generated.schema.type.entityReference import EntityReference
from metadata.generated.schema.type.entityReferenceList import EntityReferenceList
from metadata.generated.schema.type.filterPattern import FilterPattern
from metadata.generated.schema.type.lifeCycle import AccessDetails, LifeCycle
from metadata.ingestion.api.models import Either
from metadata.ingestion.models.patch_request import (
ALLOWED_COMMON_PATCH_FIELDS,
RESTRICT_UPDATE_LIST,
build_patch,
)
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.ingestion.source.dashboard.sigma.client import SigmaApiClient
from metadata.ingestion.source.dashboard.sigma.metadata import SigmaSource
Expand Down Expand Up @@ -1632,3 +1638,127 @@ def test_dashboard_records_when_the_workbook_was_created_and_updated(sigma_over_
assert dashboard.lifeCycle == LifeCycle(
created=AccessDetails(timestamp=1713188691477), updated=AccessDetails(timestamp=1713189117302)
)


class FakeDashboardProperties:
"""OpenMetadata's dashboard custom properties and the Sigma dashboard, as the server holds them"""

def __init__(self, properties=(), extension=None):
self.properties = [{"name": name, "propertyType": {"name": data_type}} for name, data_type in properties]
self.registered = []
self.dashboard = LineageDashboard(
id=uuid5(NAMESPACE_URL, "wb-1"),
name="wb-1",
fullyQualifiedName="mock_sigma.wb-1",
service=EntityReference(id=MOCK_DASHBOARD_SERVICE.id, type="dashboardService"),
extension=EntityExtension(extension) if extension else None,
)

def serve(self, source):
source.metadata.get_entity_custom_properties = lambda entity_type: self.properties
source.metadata.get_property_type_ref = lambda data_type: PropertyType(
EntityReference(id=uuid5(NAMESPACE_URL, data_type.value), type="type", name=data_type.value)
)
source.metadata.create_or_update_custom_property = self.register
source.metadata.get_by_name = lambda entity, fqn, fields=None: (
self.dashboard if fqn == self.dashboard.fullyQualifiedName.root else None
)

def register(self, record):
request = record.createCustomPropertyRequest
self.registered.append((request.name.root, request.propertyType.root.name))
self.properties.append({"name": request.name.root, "propertyType": {"name": request.propertyType.root.name}})


def patched_extension(source, workbook_id="wb-1"):
"""The extension the dashboard holds once the sink applies the workbook's patch"""
details = source.get_dashboard_details(Workbook(workbookId=workbook_id))
requests_sent = [either.right for either in source.yield_dashboard_extension(details)]
if not requests_sent:
return None
(request,) = requests_sent
dashboard_patch = build_patch(
source=request.original_entity,
destination=request.new_entity,
allowed_fields=ALLOWED_COMMON_PATCH_FIELDS,
restrict_update_fields=RESTRICT_UPDATE_LIST,
override_metadata=request.override_metadata,
)
assert all(op["path"].startswith("/extension") and op["op"] != "remove" for op in dashboard_patch.patch)
return dashboard_patch.apply(request.original_entity.model_dump(mode="json", exclude_none=True))["extension"]


@pytest.mark.parametrize("version", [3, 1.1])
def test_the_workbook_version_is_patched_onto_its_dashboard(sigma_over_http, routes, version):
source, _ = sigma_over_http
source.source_config.includeCustomProperties = True
routes["GET", "/v2/workbooks/wb-1"] = {**routes["GET", "/v2/workbooks/wb-1"], "latestVersion": version}
server = FakeDashboardProperties(extension={"team": "finance", "latestVersion": 2})
server.serve(source)

assert patched_extension(source) == {"team": "finance", "latestVersion": version}
assert patched_extension(source, "wb-2") is None
assert server.registered == [("latestVersion", "number")]


def test_a_latest_version_property_of_another_type_is_left_alone(sigma_over_http):
source, _ = sigma_over_http
source.source_config.includeCustomProperties = True
server = FakeDashboardProperties(properties=[("latestVersion", "string")])
server.serve(source)

assert patched_extension(source) is None
assert server.registered == []


def test_no_workbook_version_is_set_without_custom_properties(sigma_over_http):
source, _ = sigma_over_http
server = FakeDashboardProperties()
server.serve(source)

assert patched_extension(source) is None
assert server.registered == []


def test_a_failed_registration_sets_no_version_and_is_not_retried(sigma_over_http):
source, _ = sigma_over_http
source.source_config.includeCustomProperties = True
server = FakeDashboardProperties()
server.serve(source)
attempts = []

def refuse(record):
attempts.append(record.createCustomPropertyRequest.name.root)
raise requests.HTTPError("403 Forbidden")

source.metadata.create_or_update_custom_property = refuse

assert patched_extension(source) is None
assert patched_extension(source, "wb-2") is None
assert attempts == ["latestVersion"]


def test_a_registered_latest_version_property_is_reused(sigma_over_http):
source, _ = sigma_over_http
source.source_config.includeCustomProperties = True
server = FakeDashboardProperties(properties=[("latestVersion", "number")])
server.serve(source)

assert patched_extension(source) == {"latestVersion": 3}
assert server.registered == []


def test_a_failed_dashboard_read_is_reported_for_the_workbook(sigma_over_http):
source, _ = sigma_over_http
source.source_config.includeCustomProperties = True
FakeDashboardProperties().serve(source)

def unreachable(entity, fqn, fields=None):
raise requests.ConnectionError("OpenMetadata unreachable")

source.metadata.get_by_name = unreachable
details = source.get_dashboard_details(Workbook(workbookId="wb-1"))

(either,) = source.yield_dashboard_extension(details)
assert either.right is None
assert "Sigma workbook wb-1: OpenMetadata unreachable" in either.left.error
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ $$

When **Include Data Models** is on, each Sigma Data Model is ingested as one data model, with a table column per data model element holding that element's columns. **Data Model Filter Pattern** matches the Sigma Data Model name. A workbook element that reads a Sigma Data Model gets lineage from it.

## Custom Properties

When **Include Custom Properties** is on, each workbook's dashboard gets a `latestVersion` custom property: the most recently published version of the workbook in Sigma. The property is added to every dashboard in OpenMetadata, and is left alone when a property of that name already exists with another type.

## Lineage

The Sigma connector extracts lineage by parsing SQL queries from workbooks to identify source tables. If SQL queries are unavailable, it falls back to Sigma's lineage API to retrieve metadata-based lineage information.
Expand Down
Loading