Get the SQL query for a data model element
This endpoint retrieves the underlying SQL query associated with a specific element in a data model. It allows users to view and understand how the data for that element is being processed and transformed, which is useful for debugging, optimization, and educational purposes.
Usage notes
- Retrieve the dataModelId by calling the /v2/dataModels endpoint.
- Retrieve the elementId by calling the /v2/dataModels/{dataModelId}/elements endpoint.
- To retrieve the query for an element from a version-tagged data model, pass the
tagNamein the query parameters with the tag name. Retrieve the tag name by calling the /v2/dataModels/{dataModelId}/tags endpoint and using thetagNameincluded in the response for a given data model.
Usage scenarios
- Development and debugging: Provides developers and analysts with the ability to retrieve and review the SQL code behind data model elements, facilitating troubleshooting and enhancements.
- Educational insight: Useful for training purposes or for users learning to understand the impact of various transformations and filters applied within their Sigma data models.
Best practices
- Restrict who can retrieve query SQL with folder and document permissions. Column-level security (CLS) still applies to the data returned by those queries.
- Use this endpoint as part of a regular review process to ensure that all queries are optimized and up to date with current data schemas.
Authentication
AuthorizationBearer
OAuth authentication of the form <token>.
Path parameters
dataModelId
Unique identifier of the data model.
elementId
Unique identifier of the data model element.
Query parameters
tagName
Response
The response body.
elementId
name
sql
error

