:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add Sigma Computing source (#78858)
Tom Owersde33464e3223
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex 6ebbfe6cdbee..d99c62460fe5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -580,6 +580,7 @@ the row lists both.| shortcut | HTTP | requests | ✅ || shortio | HTTP | requests | ✅ || shutterstock | HTTP | requests + `rest_source.RESTClient` | ✅ |+| sigma_computing | HTTP | requests + `rest_source.RESTClient` | ✅ || signoz | HTTP | requests | ✅ || simfin | HTTP | requests | ✅ || similarweb | HTTP | requests | ✅ |@@ -1331,7 +1332,6 @@ doesn't conflict with concurrent PRs.- shopwired- shortio- sideshift-- sigma_computing- signnow- sim- simplecastdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/sigmacomputing.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/sigmacomputing.pyindex fa8a4f1c8624..169b9830e266 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/sigmacomputing.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/sigmacomputing.py@@ -1,9 +1,27 @@# This file is automatically generated from `SourceRegistry.get_all_sources()`# Do not edit manually - run `pnpm generate:source-configs` to regenerate.+from typing import Literal+from products.warehouse_sources.backend.temporal.data_imports.sources.common import config@config.configclass SigmaComputingSourceConfig(config.Config):- pass+ client_id: str+ client_secret: str+ region: Literal[+ "gcp_us",+ "gcp_sa",+ "aws_us_west",+ "aws_us_east",+ "aws_ca",+ "aws_eu",+ "aws_au",+ "aws_uk",+ "azure_us",+ "azure_eu",+ "azure_ca",+ "azure_uk",+ "azure_au",+ ] = config.value(default="gcp_us")diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/canonical_descriptions.pynew file mode 100644index 000000000000..0a78b2cd6cce--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/canonical_descriptions.py@@ -0,0 +1,145 @@+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "Workbooks": {+ "description": "A Sigma workbook: a saved collection of pages, elements, and visualizations built on top of one or more data sources.",+ "docs_url": "https://help.sigmacomputing.com/reference/listworkbooks",+ "columns": {+ "workbookId": "Unique identifier for the workbook.",+ "workbookUrlId": "Base62-encoded identifier used in the workbook's URL.",+ "name": "Name of the workbook.",+ "url": "URL to open the workbook in Sigma.",+ "path": "Folder path where the workbook is stored.",+ "latestVersion": "Version number of the workbook's latest published revision.",+ "ownerId": "Member ID of the workbook's current owner.",+ "createdBy": "Member ID of the user who created the workbook.",+ "updatedBy": "Member ID of the user who last updated the workbook.",+ "createdAt": "Timestamp when the workbook was created.",+ "updatedAt": "Timestamp when the workbook was last updated.",+ "isArchived": "Whether the workbook has been archived.",+ "description": "Free-text description of the workbook.",+ },+ },+ "DataModels": {+ "description": "A Sigma data model: a governed, reusable dataset built from one or more connections, the successor to the deprecated Datasets feature.",+ "docs_url": "https://help.sigmacomputing.com/reference/list-data-models",+ "columns": {+ "dataModelId": "Unique identifier for the data model.",+ "dataModelUrlId": "Base62-encoded identifier used in the data model's URL.",+ "name": "Name of the data model.",+ "url": "URL to open the data model in Sigma.",+ "path": "Folder path where the data model is stored.",+ "latestVersion": "Version number of the data model's latest published revision.",+ "ownerId": "Member ID of the data model's current owner.",+ "createdBy": "Member ID of the user who created the data model.",+ "updatedBy": "Member ID of the user who last updated the data model.",+ "createdAt": "Timestamp when the data model was created.",+ "updatedAt": "Timestamp when the data model was last updated.",+ "isArchived": "Whether the data model has been archived.",+ },+ },+ "Connections": {+ "description": "A Sigma connection: the credentials and configuration Sigma uses to query an external warehouse or database.",+ "docs_url": "https://help.sigmacomputing.com/reference/listconnections",+ "columns": {+ "connectionId": "Unique identifier for the connection.",+ "organizationId": "Identifier of the organization that owns the connection.",+ "name": "Name of the connection.",+ "type": "Type of the connected warehouse or database (e.g. snowflake, bigquery).",+ "isSample": "Whether this is Sigma's built-in sample data connection.",+ "isAuditLog": "Whether this connection is used to store Sigma's audit log data.",+ "isArchived": "Whether the connection has been archived.",+ "useOauth": "Whether the connection authenticates via OAuth rather than static credentials.",+ "lastActiveAt": "Timestamp when the connection was last used to run a query.",+ "createdBy": "Member ID of the user who created the connection.",+ "updatedBy": "Member ID of the user who last updated the connection.",+ "createdAt": "Timestamp when the connection was created.",+ "updatedAt": "Timestamp when the connection was last updated.",+ },+ },+ "Teams": {+ "description": "A Sigma team: a named group of members used to manage sharing and permissions.",+ "docs_url": "https://help.sigmacomputing.com/reference/listteams",+ "columns": {+ "teamId": "Unique identifier for the team.",+ "name": "Name of the team.",+ "description": "Free-text description of the team.",+ "visibility": "Whether the team is public or private within the organization.",+ "isArchived": "Whether the team has been archived.",+ "createdBy": "Member ID of the user who created the team.",+ "updatedBy": "Member ID of the user who last updated the team.",+ "createdAt": "Timestamp when the team was created.",+ "updatedAt": "Timestamp when the team was last updated.",+ },+ },+ "Members": {+ "description": "A Sigma member: a user account within the organization.",+ "docs_url": "https://help.sigmacomputing.com/reference/listmembers",+ "columns": {+ "memberId": "Unique identifier for the member.",+ "organizationId": "Identifier of the organization the member belongs to.",+ "memberType": "The member's role/type within the organization.",+ "firstName": "Member's first name.",+ "lastName": "Member's last name.",+ "email": "Member's email address.",+ "profileImgUrl": "URL of the member's profile image.",+ "homeFolderId": "Identifier of the member's home folder.",+ "userKind": "Whether the member is a human user or a service/embed identity.",+ "isArchived": "Whether the member has been deactivated.",+ "isInactive": "Whether the member is currently marked inactive.",+ "createdBy": "Member ID of the user who created this member record.",+ "updatedBy": "Member ID of the user who last updated this member record.",+ "createdAt": "Timestamp when the member was created.",+ "updatedAt": "Timestamp when the member was last updated.",+ },+ },+ "Workspaces": {+ "description": "A Sigma workspace: a shared folder area used to organize workbooks, data models, and connections.",+ "docs_url": "https://help.sigmacomputing.com/reference/listworkspaces",+ "columns": {+ "workspaceId": "Unique identifier for the workspace.",+ "workspaceUrlId": "Base62-encoded identifier used in the workspace's URL.",+ "name": "Name of the workspace.",+ "createdBy": "Member ID of the user who created the workspace.",+ "updatedBy": "Member ID of the user who last updated the workspace.",+ "createdAt": "Timestamp when the workspace was created.",+ "updatedAt": "Timestamp when the workspace was last updated.",+ },+ },+ "WorkbookElements": {+ "description": "An element (chart, table, or control) placed on a page within a Sigma workbook.",+ "docs_url": "https://help.sigmacomputing.com/reference/listworkbookelements",+ "columns": {+ "workbookId": "Identifier of the workbook this element belongs to.",+ "elementId": "Unique identifier for the element, within its workbook.",+ "name": "Name of the element.",+ "type": "The element's type (e.g. chart, table, viz).",+ "columns": "Column names the element pulls from its underlying data source.",+ "vizualizationType": "The visualization type rendered by the element, when applicable.",+ "error": "Error message if the element failed to compute, otherwise empty.",+ },+ },+ "WorkbookPages": {+ "description": "A page within a Sigma workbook, grouping the elements shown on one tab.",+ "docs_url": "https://help.sigmacomputing.com/reference/listworkbookpages",+ "columns": {+ "workbookId": "Identifier of the workbook this page belongs to.",+ "pageId": "Unique identifier for the page, within its workbook.",+ "name": "Name of the page.",+ "hidden": "Whether the page is hidden from viewers.",+ },+ },+ "WorkbookQueries": {+ "description": "The generated SQL query behind one element of a Sigma workbook, used to audit what a workbook actually runs against its data source.",+ "docs_url": "https://help.sigmacomputing.com/reference/list-workbook-queries",+ "columns": {+ "workbookId": "Identifier of the workbook this query belongs to.",+ "elementId": "Identifier of the element the query was generated for, within its workbook.",+ "name": "Name of the element the query was generated for.",+ "sql": "The generated SQL text Sigma runs for this element.",+ "error": "Error message if the query failed to generate, otherwise empty.",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/settings.pynew file mode 100644index 000000000000..9a5ce5e9a292--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/settings.py@@ -0,0 +1,134 @@+from dataclasses import field++from posthog.dataclasses import frozen++from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ DependentEndpointConfig,+)+from products.warehouse_sources.backend.types import IncrementalField++# Sigma's list endpoints default `limit` to 50 and cap it at 1000; always ask for the max to+# minimize round trips per sync.+PAGE_SIZE = 1000++# A Sigma org's cloud deployment is chosen when the org is created and can never be migrated, so+# the host is a fixed, non-secret enum rather than free text.+# https://help.sigmacomputing.com/docs/region-warehouse-and-feature-support+REGION_HOSTS: dict[str, str] = {+ "gcp_us": "api.sigmacomputing.com",+ "gcp_sa": "api.sa.gcp.sigmacomputing.com",+ "aws_us_west": "aws-api.sigmacomputing.com",+ "aws_us_east": "api.us-a.aws.sigmacomputing.com",+ "aws_ca": "api.ca.aws.sigmacomputing.com",+ "aws_eu": "api.eu.aws.sigmacomputing.com",+ "aws_au": "api.au.aws.sigmacomputing.com",+ "aws_uk": "api.uk.aws.sigmacomputing.com",+ "azure_us": "api.us.azure.sigmacomputing.com",+ "azure_eu": "api.eu.azure.sigmacomputing.com",+ "azure_ca": "api.ca.azure.sigmacomputing.com",+ "azure_uk": "api.uk.azure.sigmacomputing.com",+ "azure_au": "api.au.azure.sigmacomputing.com",+}++DEFAULT_REGION = "gcp_us"+++def resolve_base_url(region: str) -> str:+ host = REGION_HOSTS.get(region)+ if host is None:+ raise ValueError(f"Unknown Sigma Computing deployment region: {region}")+ return f"https://{host}"+++# Shared by every workbook-scoped child endpoint: the parent's `workbookId` is injected under+# `_Workbooks_workbookId` by the fan-out framework, then renamed back to the bare `workbookId` so+# it lines up with each child's composite primary key.+WORKBOOK_FANOUT = DependentEndpointConfig(+ parent_name="Workbooks",+ resolve_param="workbookId",+ resolve_field="workbookId",+ include_from_parent=["workbookId"],+ parent_field_renames={"workbookId": "workbookId"},+)+++@frozen+class SigmaComputingEndpointConfig:+ name: str+ path: str+ primary_key: str | list[str]+ # Elements/pages/queries are workbook-scoped sub-resources with no created/updated+ # timestamp of their own, so they carry no partition key.+ partition_key: str | None = "createdAt"+ page_size: int = PAGE_SIZE+ # Sigma's list endpoints expose no server-side updated-since filter, so every table below+ # is full refresh only; these two fields exist only to satisfy the fan-out helper's protocol.+ incremental_fields: list[IncrementalField] = field(default_factory=list)+ default_incremental_field: str | None = None+ fanout: DependentEndpointConfig | None = None+++SIGMA_ENDPOINTS: dict[str, SigmaComputingEndpointConfig] = {+ "Workbooks": SigmaComputingEndpointConfig(+ name="Workbooks",+ path="/v2/workbooks",+ primary_key="workbookId",+ ),+ # Sigma deprecated creating/editing Datasets in favor of Data models on June 2, 2026; Data+ # models is the actively maintained equivalent going forward, so it's the table shipped here+ # instead of the legacy /v2/datasets endpoint.+ "DataModels": SigmaComputingEndpointConfig(+ name="DataModels",+ path="/v2/dataModels",+ primary_key="dataModelId",+ ),+ "Connections": SigmaComputingEndpointConfig(+ name="Connections",+ path="/v2/connections",+ primary_key="connectionId",+ ),+ "Teams": SigmaComputingEndpointConfig(+ name="Teams",+ path="/v2/teams",+ primary_key="teamId",+ ),+ "Members": SigmaComputingEndpointConfig(+ name="Members",+ path="/v2/members",+ primary_key="memberId",+ ),+ "Workspaces": SigmaComputingEndpointConfig(+ name="Workspaces",+ path="/v2/workspaces",+ primary_key="workspaceId",+ ),+ "WorkbookElements": SigmaComputingEndpointConfig(+ name="WorkbookElements",+ path="/v2/workbooks/{workbookId}/elements",+ # elementId is only documented unique within its workbook.+ primary_key=["workbookId", "elementId"],+ partition_key=None,+ fanout=WORKBOOK_FANOUT,+ ),+ "WorkbookPages": SigmaComputingEndpointConfig(+ name="WorkbookPages",+ path="/v2/workbooks/{workbookId}/pages",+ primary_key=["workbookId", "pageId"],+ partition_key=None,+ fanout=WORKBOOK_FANOUT,+ ),+ "WorkbookQueries": SigmaComputingEndpointConfig(+ name="WorkbookQueries",+ path="/v2/workbooks/{workbookId}/queries",+ # Entries carry no dedicated query id; elementId is unique per workbook.+ primary_key=["workbookId", "elementId"],+ partition_key=None,+ fanout=WORKBOOK_FANOUT,+ ),+}++ENDPOINTS = tuple(SIGMA_ENDPOINTS)++# None of Sigma's list endpoints document a server-side updated-since filter (only non-date+# filters like isArchived/search/visibility), so every table above is full refresh only.+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: [] for name in SIGMA_ENDPOINTS}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/sigma_computing.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/sigma_computing.pynew file mode 100644index 000000000000..8bb418343832--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/sigma_computing.py@@ -0,0 +1,221 @@+from typing import Any, Optional, cast++import requests++from posthog.dataclasses import frozen++from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (+ RESTAPIConfig,+ rest_api_resource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ build_dependent_resource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (+ ClientConfig,+ Endpoint,+ EndpointResource,+ PaginatorConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.settings import (+ SIGMA_ENDPOINTS,+ SigmaComputingEndpointConfig,+ resolve_base_url,+)++TOKEN_ERROR = "Sigma rejected the API client credentials"+VALIDATE_TIMEOUT = 15+++class SigmaAuthError(Exception):+ pass+++@frozen+class SigmaComputingResumeConfig:+ # Opaque framework checkpoint: `{"cursor": ...}` for a top-level endpoint's+ # JSONResponseCursorPaginator, or the fan-out manager's combined state for a workbook-scoped+ # child endpoint - round-tripped into `initial_paginator_state` on resume. Frozen since it's+ # only ever constructed fresh and handed to `resumable_source_manager.save_state`.+ paginator_state: dict[str, Any]+++def _paginator_config() -> PaginatorConfig:+ return {"type": "cursor", "cursor_path": "nextPage", "cursor_param": "page"}+++def _client_config(base_url: str, client_id: str, client_secret: str) -> ClientConfig:+ return {+ "base_url": base_url,+ "headers": {"Accept": "application/json"},+ # The framework auth mints (and re-mints on expiry) the ~1h access token, and redacts the+ # client secret / access token from logs and samples.+ "auth": {+ "type": "oauth2",+ "token_url": f"{base_url}/v2/auth/token",+ "client_id": client_id,+ "client_secret": client_secret,+ "grant_type": "client_credentials",+ },+ }+++def get_resource(name: str) -> EndpointResource:+ config = SIGMA_ENDPOINTS[name]+ endpoint: Endpoint = {+ "path": config.path,+ "data_selector": "entries",+ "params": {"limit": config.page_size},+ "paginator": _paginator_config(),+ }+ return {+ "name": config.name,+ "table_name": config.name,+ "write_disposition": "replace",+ "endpoint": endpoint,+ "table_format": "delta",+ }+++def _mint_token(base_url: str, client_id: str, client_secret: str) -> str:+ session = make_tracked_session(redact_values=(client_secret,))+ try:+ response = session.post(+ f"{base_url}/v2/auth/token",+ data={"grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret},+ timeout=VALIDATE_TIMEOUT,+ )+ except requests.exceptions.RequestException as e:+ raise SigmaAuthError(str(e)) from e++ if response.status_code != 200:+ raise SigmaAuthError(f"{TOKEN_ERROR} (HTTP {response.status_code})")++ token = response.json().get("access_token")+ if not isinstance(token, str) or not token:+ raise SigmaAuthError(f"{TOKEN_ERROR}: no access token returned")+ return token+++def validate_credentials(+ region: str,+ client_id: str,+ client_secret: str,+ schema_name: Optional[str] = None,+) -> tuple[bool, str | None]:+ """Mint a token, then probe the cheap Workbooks list to confirm the client can read the org.++ At source-create (`schema_name is None`) a 403 is accepted: the client credentials are+ genuine but may simply lack the Workbooks scope while holding others. A scoped probe (a+ specific schema being checked) treats 403 as a hard failure.+ """+ try:+ base_url = resolve_base_url(region)+ except ValueError as e:+ return False, str(e)++ try:+ token = _mint_token(base_url, client_id, client_secret)+ except SigmaAuthError as e:+ return False, str(e)++ ok, status = validate_via_probe(+ lambda: make_tracked_session(redact_values=(client_secret, token)),+ f"{base_url}/v2/workbooks",+ headers={"Authorization": f"Bearer {token}"},+ ok_statuses=(200, 403) if schema_name is None else (200,),+ timeout=VALIDATE_TIMEOUT,+ )+ if ok:+ return True, None+ if status == 401:+ return False, "Sigma rejected the access token for this client."+ if status == 403:+ return False, "Your Sigma API client does not have permission for this resource."+ if status is None:+ return False, "Could not reach Sigma. Please check your network and try again."+ return False, f"Sigma API returned an unexpected status: {status}"+++def _make_source_response(endpoint_config: SigmaComputingEndpointConfig, items_fn: Any) -> SourceResponse:+ return SourceResponse(+ name=endpoint_config.name,+ items=items_fn,+ primary_keys=(+ endpoint_config.primary_key+ if isinstance(endpoint_config.primary_key, list)+ else [endpoint_config.primary_key]+ ),+ # No list endpoint documents an ordering guarantee or a server-side time filter, so every+ # sync is a full refresh with nothing downstream depending on row order.+ sort_mode=None,+ partition_count=1,+ partition_size=1,+ partition_mode="datetime" if endpoint_config.partition_key else None,+ partition_format="month" if endpoint_config.partition_key else None,+ partition_keys=[endpoint_config.partition_key] if endpoint_config.partition_key else None,+ )+++def sigma_computing_source(+ region: str,+ client_id: str,+ client_secret: str,+ endpoint: str,+ team_id: int,+ job_id: str,+ resumable_source_manager: ResumableSourceManager[SigmaComputingResumeConfig],+) -> SourceResponse:+ endpoint_config = SIGMA_ENDPOINTS[endpoint]+ base_url = resolve_base_url(region)+ client_config = _client_config(base_url, client_id, client_secret)++ initial_paginator_state: Optional[dict[str, Any]] = None+ if resumable_source_manager.can_resume():+ resume_config = resumable_source_manager.load_state()+ if resume_config is not None:+ initial_paginator_state = resume_config.paginator_state++ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:+ # Only persist when there's a next page to resume to; the manager's 24h Redis TTL handles+ # cleanup once a sync completes.+ if state:+ resumable_source_manager.save_state(SigmaComputingResumeConfig(paginator_state=dict(state)))++ if endpoint_config.fanout:+ dependent_resource = build_dependent_resource(+ endpoint_configs=cast(Any, SIGMA_ENDPOINTS),+ child_endpoint=endpoint,+ fanout=endpoint_config.fanout,+ client_config=client_config,+ path_format_values={},+ team_id=team_id,+ job_id=job_id,+ db_incremental_field_last_value=None,+ page_size_param="limit",+ parent_endpoint_extra={"paginator": _paginator_config(), "data_selector": "entries"},+ child_endpoint_extra={"paginator": _paginator_config(), "data_selector": "entries"},+ resume_hook=save_checkpoint,+ initial_paginator_state=initial_paginator_state,+ )+ return _make_source_response(endpoint_config, lambda: dependent_resource)++ config: RESTAPIConfig = {+ "client": client_config,+ "resource_defaults": {},+ "resources": [get_resource(endpoint)],+ }++ resource = rest_api_resource(+ config,+ team_id,+ job_id,+ None,+ resume_hook=save_checkpoint,+ initial_paginator_state=initial_paginator_state,+ )+ return _make_source_response(endpoint_config, lambda: resource)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/source.pyindex 7e9b59590cc7..7d360229f63f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/source.py@@ -1,32 +1,173 @@-from typing import cast+from typing import Optional, castfrom posthog.schema import (DataWarehouseSourceCategory,ExternalDataSourceType as SchemaExternalDataSourceType,+ ReleaseStatus,SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,+ SourceFieldSelectConfig,+ SourceFieldSelectConfigOption,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (+ SourceSchema,+ build_endpoint_schemas,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.sigmacomputing import (SigmaComputingSourceConfig,)+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.settings import (+ DEFAULT_REGION,+ ENDPOINTS,+ INCREMENTAL_FIELDS,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.sigma_computing import (+ SigmaComputingResumeConfig,+ sigma_computing_source,+ validate_credentials as validate_sigma_computing_credentials,+)from products.warehouse_sources.backend.types import ExternalDataSourceType+REGION_OPTIONS = [+ SourceFieldSelectConfigOption(label="GCP - United States (Iowa)", value="gcp_us"),+ SourceFieldSelectConfigOption(label="GCP - Saudi Arabia (Dammam)", value="gcp_sa"),+ SourceFieldSelectConfigOption(label="AWS - United States West (Oregon)", value="aws_us_west"),+ SourceFieldSelectConfigOption(label="AWS - United States East (N. Virginia)", value="aws_us_east"),+ SourceFieldSelectConfigOption(label="AWS - Canada (Central)", value="aws_ca"),+ SourceFieldSelectConfigOption(label="AWS - Europe (Frankfurt)", value="aws_eu"),+ SourceFieldSelectConfigOption(label="AWS - Asia Pacific (Sydney)", value="aws_au"),+ SourceFieldSelectConfigOption(label="AWS - United Kingdom (London)", value="aws_uk"),+ SourceFieldSelectConfigOption(label="Azure - United States (Virginia)", value="azure_us"),+ SourceFieldSelectConfigOption(label="Azure - Europe (Netherlands)", value="azure_eu"),+ SourceFieldSelectConfigOption(label="Azure - Canada (Toronto)", value="azure_ca"),+ SourceFieldSelectConfigOption(label="Azure - United Kingdom (London)", value="azure_uk"),+ SourceFieldSelectConfigOption(label="Azure - Australia (New South Wales)", value="azure_au"),+]+@SourceRegistry.register-class SigmaComputingSource(SimpleSource[SigmaComputingSourceConfig]):+class SigmaComputingSource(ResumableSource[SigmaComputingSourceConfig, SigmaComputingResumeConfig]):+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs+ supported_versions = ("v2",)+ default_version = "v2"+ api_docs_url = "https://help.sigmacomputing.com/reference/get-started-sigma-api"+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.SIGMACOMPUTING+ @property+ def connection_host_fields(self) -> list[str]:+ # `region` picks the host the client ID/secret are sent to; retargeting it must+ # re-require those secrets.+ return ["region"]++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ "Sigma rejected the API client credentials": "Sigma rejected your API client credentials. Please check the client ID and secret and reconnect.",+ "401 Client Error": "Sigma rejected the access token. Please check the client ID and secret, then reconnect.",+ "403 Client Error": "Your Sigma API client does not have permission for this resource.",+ }++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.canonical_descriptions import (+ CANONICAL_DESCRIPTIONS,+ )++ return CANONICAL_DESCRIPTIONS++ def get_schemas(+ self,+ config: SigmaComputingSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ api_version: str | None = None,+ ) -> list[SourceSchema]:+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)++ def validate_credentials(+ self,+ config: SigmaComputingSourceConfig,+ team_id: int,+ schema_name: Optional[str] = None,+ api_version: str | None = None,+ ) -> tuple[bool, str | None]:+ return validate_sigma_computing_credentials(+ region=config.region,+ client_id=config.client_id,+ client_secret=config.client_secret,+ schema_name=schema_name,+ )++ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[SigmaComputingResumeConfig]:+ return ResumableSourceManager[SigmaComputingResumeConfig](inputs, SigmaComputingResumeConfig)++ def source_for_pipeline(+ self,+ config: SigmaComputingSourceConfig,+ resumable_source_manager: ResumableSourceManager[SigmaComputingResumeConfig],+ inputs: SourceInputs,+ ) -> SourceResponse:+ return sigma_computing_source(+ region=config.region,+ client_id=config.client_id,+ client_secret=config.client_secret,+ endpoint=inputs.schema_name,+ team_id=inputs.team_id,+ job_id=inputs.job_id,+ resumable_source_manager=resumable_source_manager,+ )+@propertydef get_source_config(self) -> SourceConfig:return SourceConfig(name=SchemaExternalDataSourceType.SIGMA_COMPUTING,category=DataWarehouseSourceCategory.ANALYTICS,label="Sigma Computing",+ caption="""Connect Sigma Computing to pull your workbook, data model, connection, and membership metadata into the PostHog Data warehouse.++Generate a client ID and secret from **Administration > Developer Access** in Sigma, then pick the deployment region shown on that same page (or under **Account > General Settings**).""",iconPath="/static/services/sigma_computing.png",- fields=cast(list[FieldType], []),- unreleasedSource=True,+ docsUrl="https://posthog.com/docs/cdp/sources/sigma-computing",+ releaseStatus=ReleaseStatus.ALPHA,+ keywords=["bi", "business intelligence"],+ fields=cast(+ list[FieldType],+ [+ SourceFieldSelectConfig(+ name="region",+ label="Deployment region",+ required=True,+ defaultValue=DEFAULT_REGION,+ options=REGION_OPTIONS,+ ),+ SourceFieldInputConfig(+ name="client_id",+ label="Client ID",+ type=SourceFieldInputConfigType.TEXT,+ required=True,+ placeholder="",+ secret=False,+ ),+ SourceFieldInputConfig(+ name="client_secret",+ label="Client secret",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="",+ secret=True,+ ),+ ],+ ),)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/tests/test_sigma_computing.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/tests/test_sigma_computing.pynew file mode 100644index 000000000000..da7000f19bce--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/tests/test_sigma_computing.py@@ -0,0 +1,338 @@+from collections.abc import Iterable+from typing import Any, Optional, cast+from urllib.parse import parse_qs++import pytest++from parameterized import parameterized++from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.settings import (+ REGION_HOSTS,+ resolve_base_url,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.sigma_computing import (+ SigmaComputingResumeConfig,+ get_resource,+ sigma_computing_source,+ validate_credentials,+)++BASE_URL = "https://api.sigmacomputing.com"+++class _FakeResumeManager(ResumableSourceManager[SigmaComputingResumeConfig]):+ # In-memory stand-in — deliberately doesn't call super().__init__, so no Redis is touched.+ def __init__(self, state: Optional[dict[str, Any]] = None) -> None:+ self._state = state+ self.saved: list[dict[str, Any]] = []++ def can_resume(self) -> bool:+ return self._state is not None++ def load_state(self) -> Optional[SigmaComputingResumeConfig]:+ return SigmaComputingResumeConfig(paginator_state=self._state) if self._state is not None else None++ def save_state(self, data: SigmaComputingResumeConfig) -> None:+ self.saved.append(data.paginator_state)+++def _collect_rows(response: SourceResponse) -> list[dict[str, Any]]:+ items = response.items()+ assert isinstance(items, Iterable)+ pages = cast(list[list[dict[str, Any]]], list(items))+ return [row for page in pages for row in page]+++def _mock_token(requests_mock: Any, base_url: str = BASE_URL, token: str = "tok") -> None:+ requests_mock.post(+ f"{base_url}/v2/auth/token",+ json={"access_token": token, "token_type": "Bearer", "expires_in": 3600},+ )+++class TestResolveBaseUrl:+ @parameterized.expand([(region, f"https://{host}") for region, host in REGION_HOSTS.items()])+ def test_known_regions(self, region: str, expected: str) -> None:+ assert resolve_base_url(region) == expected++ def test_unknown_region_raises(self) -> None:+ with pytest.raises(ValueError):+ resolve_base_url("mars")+++class TestGetResource:+ def test_top_level_resource_shape(self) -> None:+ resource = cast(dict[str, Any], get_resource("Workbooks"))++ assert resource["name"] == "Workbooks"+ assert resource["write_disposition"] == "replace"+ endpoint = resource["endpoint"]+ assert endpoint["path"] == "/v2/workbooks"+ assert endpoint["data_selector"] == "entries"+ assert endpoint["params"] == {"limit": 1000}+ assert endpoint["paginator"] == {"type": "cursor", "cursor_path": "nextPage", "cursor_param": "page"}+ assert resource["table_format"] == "delta"+++class TestValidateCredentials:+ def test_success(self, requests_mock: Any) -> None:+ _mock_token(requests_mock)+ requests_mock.get(f"{BASE_URL}/v2/workbooks", json={"entries": [], "nextPage": None, "total": 0})++ result = validate_credentials("gcp_us", "client", "secret")++ assert result == (True, None)+ token_request = requests_mock.request_history[0]+ assert token_request.method == "POST"+ # The token exchange is form-urlencoded, not JSON (matches Sigma's documented header).+ assert parse_qs(token_request.text) == {+ "grant_type": ["client_credentials"],+ "client_id": ["client"],+ "client_secret": ["secret"],+ }++ def test_unknown_region_is_rejected_before_any_request(self, requests_mock: Any) -> None:+ ok, error = validate_credentials("mars", "client", "secret")++ assert ok is False+ assert error is not None and "Unknown Sigma Computing deployment region" in error+ assert requests_mock.call_count == 0++ @pytest.mark.parametrize("token_status", [400, 401, 500])+ def test_token_mint_http_failure(self, requests_mock: Any, token_status: int) -> None:+ requests_mock.post(f"{BASE_URL}/v2/auth/token", status_code=token_status, json={"error": "invalid_client"})++ ok, error = validate_credentials("gcp_us", "client", "secret")++ assert ok is False+ assert error is not None and "Sigma rejected the API client credentials" in error++ def test_token_response_missing_access_token(self, requests_mock: Any) -> None:+ requests_mock.post(f"{BASE_URL}/v2/auth/token", json={"token_type": "Bearer"})++ ok, error = validate_credentials("gcp_us", "client", "secret")++ assert ok is False+ assert error is not None and "no access token returned" in error++ def test_network_failure_during_token_mint(self, requests_mock: Any) -> None:+ import requests as requests_lib++ requests_mock.post(f"{BASE_URL}/v2/auth/token", exc=requests_lib.exceptions.ConnectionError)++ ok, error = validate_credentials("gcp_us", "client", "secret")++ assert ok is False+ assert error is not None++ @pytest.mark.parametrize(+ "status_code, schema_name, expected_ok",+ [+ (200, None, True),+ (401, None, False),+ # A genuine client may hold other scopes but lack Workbooks read, so 403 must not+ # block source creation — but it fails a scoped probe for a specific table.+ (403, None, True),+ (403, "Workbooks", False),+ (500, None, False),+ ],+ )+ def test_probe_status_mapping(+ self, requests_mock: Any, status_code: int, schema_name: Optional[str], expected_ok: bool+ ) -> None:+ _mock_token(requests_mock)+ requests_mock.get(f"{BASE_URL}/v2/workbooks", status_code=status_code, json={})++ ok, _ = validate_credentials("gcp_us", "client", "secret", schema_name=schema_name)++ assert ok is expected_ok+++class TestSigmaComputingSourceTopLevel:+ def test_two_page_full_refresh_sync(self, requests_mock: Any) -> None:+ _mock_token(requests_mock)+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks",+ [+ {"json": {"entries": [{"workbookId": "wb1"}], "nextPage": "CURSOR1", "total": 2, "hasMore": True}},+ {"json": {"entries": [{"workbookId": "wb2"}], "nextPage": None, "total": 2, "hasMore": False}},+ ],+ )++ response = sigma_computing_source(+ region="gcp_us",+ client_id="client",+ client_secret="secret",+ endpoint="Workbooks",+ team_id=1,+ job_id="job-1",+ resumable_source_manager=_FakeResumeManager(),+ )+ rows = _collect_rows(response)++ assert rows == [{"workbookId": "wb1"}, {"workbookId": "wb2"}]+ assert response.primary_keys == ["workbookId"]+ assert response.sort_mode is None+ assert response.partition_keys == ["createdAt"]++ list_requests = [r for r in requests_mock.request_history if r.path == "/v2/workbooks"]+ assert list_requests[0].qs["limit"] == ["1000"]+ assert "page" not in list_requests[0].qs+ # requests_mock's `.qs` lowercases query values.+ assert list_requests[1].qs["page"] == ["cursor1"]++ def test_resumes_from_saved_cursor(self, requests_mock: Any) -> None:+ _mock_token(requests_mock)+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks",+ json={"entries": [{"workbookId": "wb2"}], "nextPage": None, "total": 1, "hasMore": False},+ )+ manager = _FakeResumeManager(state={"cursor": "SAVED_CURSOR"})++ response = sigma_computing_source(+ region="gcp_us",+ client_id="client",+ client_secret="secret",+ endpoint="Workbooks",+ team_id=1,+ job_id="job-1",+ resumable_source_manager=manager,+ )+ _collect_rows(response)++ list_requests = [r for r in requests_mock.request_history if r.path == "/v2/workbooks"]+ assert list_requests[0].qs["page"] == ["saved_cursor"]++ def test_saves_checkpoint_after_batch(self, requests_mock: Any) -> None:+ _mock_token(requests_mock)+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks",+ json={"entries": [{"workbookId": "wb1"}], "nextPage": "NEXT", "total": 2, "hasMore": True},+ )+ manager = _FakeResumeManager()++ response = sigma_computing_source(+ region="gcp_us",+ client_id="client",+ client_secret="secret",+ endpoint="Workbooks",+ team_id=1,+ job_id="job-1",+ resumable_source_manager=manager,+ )+ # The checkpoint for a page is only saved once the generator resumes past its `yield`+ # (see rest_client.paginate), so fetch the first page and then advance once more to+ # observe the checkpoint saved right after it.+ items = response.items()+ assert isinstance(items, Iterable)+ iterator = iter(items)+ next(iterator)+ next(iterator)++ assert manager.saved == [{"cursor": "NEXT"}]++ @pytest.mark.parametrize(+ "endpoint, path",+ [+ ("Workbooks", "/v2/workbooks"),+ ("DataModels", "/v2/dataModels"),+ ("Connections", "/v2/connections"),+ ("Teams", "/v2/teams"),+ ("Members", "/v2/members"),+ ("Workspaces", "/v2/workspaces"),+ ],+ )+ def test_every_top_level_endpoint_requests_its_documented_path(+ self, requests_mock: Any, endpoint: str, path: str+ ) -> None:+ _mock_token(requests_mock)+ requests_mock.get(f"{BASE_URL}{path}", json={"entries": [], "nextPage": None})++ response = sigma_computing_source(+ region="gcp_us",+ client_id="client",+ client_secret="secret",+ endpoint=endpoint,+ team_id=1,+ job_id="job-1",+ resumable_source_manager=_FakeResumeManager(),+ )+ _collect_rows(response)++ # requests_mock lowercases `.path` for case-insensitive matching (e.g. `dataModels`).+ list_requests = [r for r in requests_mock.request_history if r.path == path.lower()]+ assert len(list_requests) == 1+ assert response.name == endpoint+++class TestSigmaComputingSourceFanout:+ def test_workbook_elements_injects_parent_workbook_id(self, requests_mock: Any) -> None:+ _mock_token(requests_mock)+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks",+ json={"entries": [{"workbookId": "wb1"}, {"workbookId": "wb2"}], "nextPage": None},+ )+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks/wb1/elements",+ json={"entries": [{"elementId": "e1", "name": "Chart 1"}], "nextPage": None},+ )+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks/wb2/elements",+ json={"entries": [{"elementId": "e2", "name": "Chart 2"}], "nextPage": None},+ )++ response = sigma_computing_source(+ region="gcp_us",+ client_id="client",+ client_secret="secret",+ endpoint="WorkbookElements",+ team_id=1,+ job_id="job-1",+ resumable_source_manager=_FakeResumeManager(),+ )+ rows = _collect_rows(response)++ assert rows == [+ {"elementId": "e1", "name": "Chart 1", "workbookId": "wb1"},+ {"elementId": "e2", "name": "Chart 2", "workbookId": "wb2"},+ ]+ assert response.primary_keys == ["workbookId", "elementId"]+ assert response.partition_keys is None++ @pytest.mark.parametrize(+ "endpoint, child_path_suffix, child_row, expected_primary_keys",+ [+ ("WorkbookPages", "pages", {"pageId": "p1", "name": "Page 1"}, ["workbookId", "pageId"]),+ ("WorkbookQueries", "queries", {"elementId": "e1", "sql": "select 1"}, ["workbookId", "elementId"]),+ ],+ )+ def test_other_workbook_scoped_children(+ self,+ requests_mock: Any,+ endpoint: str,+ child_path_suffix: str,+ child_row: dict[str, Any],+ expected_primary_keys: list[str],+ ) -> None:+ _mock_token(requests_mock)+ requests_mock.get(f"{BASE_URL}/v2/workbooks", json={"entries": [{"workbookId": "wb1"}], "nextPage": None})+ requests_mock.get(+ f"{BASE_URL}/v2/workbooks/wb1/{child_path_suffix}",+ json={"entries": [child_row], "nextPage": None},+ )++ response = sigma_computing_source(+ region="gcp_us",+ client_id="client",+ client_secret="secret",+ endpoint=endpoint,+ team_id=1,+ job_id="job-1",+ resumable_source_manager=_FakeResumeManager(),+ )+ rows = _collect_rows(response)++ assert rows == [{**child_row, "workbookId": "wb1"}]+ assert response.primary_keys == expected_primary_keysdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/tests/test_sigma_computing_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/tests/test_sigma_computing_source.pynew file mode 100644index 000000000000..9b6f9cb18ce8--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sigma_computing/tests/test_sigma_computing_source.py@@ -0,0 +1,157 @@+import pytest+from unittest import mock++from posthog.schema import (+ DataWarehouseSourceCategory,+ ReleaseStatus,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,+ SourceFieldSelectConfig,+)++from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.sigmacomputing import (+ SigmaComputingSourceConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.settings import (+ ENDPOINTS,+ REGION_HOSTS,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.sigma_computing import (+ SigmaComputingResumeConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.source import (+ REGION_OPTIONS,+ SigmaComputingSource,+)+from products.warehouse_sources.backend.types import ExternalDataSourceType+++class TestSigmaComputingSource:+ def setup_method(self) -> None:+ self.source = SigmaComputingSource()+ self.team_id = 123+ self.config = SigmaComputingSourceConfig(client_id="client-id", client_secret="client-secret", region="gcp_us")++ def test_source_type(self) -> None:+ assert self.source.source_type == ExternalDataSourceType.SIGMACOMPUTING++ def test_get_source_config(self) -> None:+ config = self.source.get_source_config+ assert config.name.value == "SigmaComputing"+ assert config.label == "Sigma Computing"+ assert config.category == DataWarehouseSourceCategory.ANALYTICS+ assert config.releaseStatus == ReleaseStatus.ALPHA+ # The source ships visible: unreleasedSource hides the connector from every user.+ assert not config.unreleasedSource+ assert config.iconPath == "/static/services/sigma_computing.png"+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/sigma-computing"++ def test_connection_host_fields(self) -> None:+ # `region` picks the host the client secret is sent to, so retargeting it must+ # re-require the secret.+ assert self.source.connection_host_fields == ["region"]++ def test_region_field_options_cover_every_declared_host(self) -> None:+ config = self.source.get_source_config+ field = next(f for f in config.fields if isinstance(f, SourceFieldSelectConfig) and f.name == "region")+ assert {option.value for option in field.options} == set(REGION_HOSTS)+ assert field.required is True+ assert field.defaultValue == "gcp_us"++ def test_region_options_constant_matches_settings(self) -> None:+ assert {option.value for option in REGION_OPTIONS} == set(REGION_HOSTS)++ def test_client_secret_field_is_secret_password(self) -> None:+ config = self.source.get_source_config+ field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "client_secret")+ assert field.type == SourceFieldInputConfigType.PASSWORD+ assert field.secret is True+ assert field.required is True++ def test_client_id_field_is_not_secret(self) -> None:+ config = self.source.get_source_config+ field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "client_id")+ assert field.secret is False+ assert field.required is True++ def test_get_schemas_endpoints(self) -> None:+ schemas = self.source.get_schemas(self.config, self.team_id)+ assert {s.name for s in schemas} == set(ENDPOINTS)++ def test_get_schemas_are_full_refresh_only(self) -> None:+ # Sigma's list endpoints expose no server-side updated-since filter.+ schemas = self.source.get_schemas(self.config, self.team_id)+ for schema in schemas:+ assert schema.supports_incremental is False+ assert schema.incremental_fields == []++ def test_get_schemas_filtered_by_names(self) -> None:+ schemas = self.source.get_schemas(self.config, self.team_id, names=["Workbooks"])+ assert len(schemas) == 1+ assert schemas[0].name == "Workbooks"++ @pytest.mark.parametrize(+ "observed_error",+ [+ "401 Client Error: Unauthorized for url: https://api.sigmacomputing.com/v2/workbooks",+ "403 Client Error: Forbidden for url: https://api.sigmacomputing.com/v2/workbooks",+ "Sigma rejected the API client credentials (HTTP 401)",+ ],+ )+ def test_non_retryable_errors_match_auth_failures(self, observed_error: str) -> None:+ non_retryable = self.source.get_non_retryable_errors()+ assert any(key in observed_error for key in non_retryable)++ def test_non_retryable_errors_ignore_transient_failures(self) -> None:+ non_retryable = self.source.get_non_retryable_errors()+ assert not any(+ key in "500 Server Error for url: https://api.sigmacomputing.com/v2/workbooks" for key in non_retryable+ )++ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.source.validate_sigma_computing_credentials"+ )+ def test_validate_credentials_plumbs_arguments(self, mock_validate: mock.MagicMock) -> None:+ mock_validate.return_value = (True, None)++ result = self.source.validate_credentials(self.config, self.team_id, schema_name="Workbooks")++ assert result == (True, None)+ mock_validate.assert_called_once_with(+ region="gcp_us",+ client_id="client-id",+ client_secret="client-secret",+ schema_name="Workbooks",+ )++ def test_get_resumable_source_manager_binds_resume_config(self) -> None:+ inputs = mock.MagicMock()+ manager = self.source.get_resumable_source_manager(inputs)+ assert isinstance(manager, ResumableSourceManager)+ assert manager._data_class is SigmaComputingResumeConfig++ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.sigma_computing.source.sigma_computing_source"+ )+ def test_source_for_pipeline_plumbs_arguments(self, mock_sigma_source: mock.MagicMock) -> None:+ inputs = mock.MagicMock()+ inputs.schema_name = "WorkbookElements"+ inputs.team_id = self.team_id+ inputs.job_id = "job-1"+ manager = mock.MagicMock()++ self.source.source_for_pipeline(self.config, manager, inputs)++ kwargs = mock_sigma_source.call_args.kwargs+ assert kwargs["region"] == "gcp_us"+ assert kwargs["client_id"] == "client-id"+ assert kwargs["client_secret"] == "client-secret"+ assert kwargs["endpoint"] == "WorkbookElements"+ assert kwargs["team_id"] == self.team_id+ assert kwargs["job_id"] == "job-1"+ assert kwargs["resumable_source_manager"] is manager++ def test_canonical_descriptions_cover_endpoints(self) -> None:+ descriptions = self.source.get_canonical_descriptions()+ assert set(descriptions.keys()) == set(ENDPOINTS)