Overview
Use the Semantic Query API to send Semantic SQL Queries. The Query Generator API allows you to leverage your data in Data 360 through Tableau Semantics in order to answer a variety of business questions.
First, start with an existing Semantic Model or build a new Semantic Model through the Tableau Semantics Authoring Experience or Authoring API. Then, you can use the Semantic Semantic Query API to send Semantic Queries that leverage your Tableau Semantics data (including any Semantic Definitions and Relationships) in order to obtain exact results for each business case by using the various query parameters, such as filters, grouping, sorting, and total options.
The Semantic Query is a logical request that defines what data to retrieve from the Semantic Model. It’s processed by the Semantic Query Generator, which translates the request into optimized SQL over Data 360 objects, runs it in the context of your tenant, and returns the results. The Semantic Query is composed of the following properties:
- A list of field identifiers, including: the Data 360 Object type (DMO, DLO, or CI), the Data 360 Object ID, and the ID or name of the columns in the query.
- Selected fields.
- Grouping by field list.
- Aggregation object per field which defines the aggregation method (None, Sum, Min, Max, Average, Auto, Custom).
- Filters, which are composite objects that include a variety of filtering conditions and the composite AND/OR fields of these objects.
A Semantic Query is first sent to a gateway service and then the metadata associated with the objects being queried (Semantic Model Objects and Semantic Definitions) is fetched from Salesforce Core and Data 360. The SQL query is then generated and executed.
The Semantic Query API accepts a Semantic Query as a parameter and queries the query contents, including the Semantic Data Model along with other Data 360 service parameters (authorization, tenancy, etc.) The logical flow of the query is the following:
- Identify the Semantic Data Model from the query.
- Fetch the needed relationships and calculated field objects from the Semantic Data Model.
- Generate the SQL expression needed in order to return the result while considering the relationships (for joins), calculated fields (for generating SQL in the “select” clause), group by fields (for generating the grouping), and filters (for generating the “where” clause).
The Semantic Query model holds the context of the Semantic query. Only objects within the scope of the query model can be queried.
The Semantic Query can be executed with a specific Semantic Model ID. You can create a Semantic Model through the Authoring Experience UI or API or use an existing model with the Semantic Query.
The following is an example of a Semantic Query with a Semantic Model ID:
The following is an example of a Semantic Query with a Semantic Model: