Query Templates
ÃÛ¶¹ÊÓƵ Experience Platform Query Service allows you to save and reuse SQL code in the form of query templates. Templates save effort by avoiding the repetition of commonly performed tasks. You can share templates within your organization and easily change the query values without needing to access or understand the underlying SQL.
This document provides the information required to create query templates in Query Service.
Prerequisites
You must have the Manage queries permission enabled to access the Query Editor and view the queries dashboard within the Platform UI. The permission is enabled through the ÃÛ¶¹ÊÓƵ . Please contact your organization’s administrator if you do not have administrator privileges to enable this permission. See the access control documentation for full instructions on adding permissions through Admin Console.
Create a query template
You can create query templates through two methods, either by making a POST request to the Query Service API query-templates
endpoint, or by writing, naming, and saving a query through the Query Editor.
Use the Query Editor to author and save a query as a template
See the documentation for instructions on how to use the Query Editor to write and save queries. Once you have named and saved your query, it is available to be reused as a query template from the Templates tab.
Browse query templates browse
From the Queries workspace of the Platform UI, select Templates to display the list of available saved queries.
To find relevant template information, select any query template from the available list to open the details panel.
From the details panel you can execute the following actions:
- Select Run as CTAS to create a new table by selecting data from an existing table or tables. This option is only available if you have a SELECT query.
- Select Add schedule to begin editing your schedule for your query template.
- Select View schedule to navigate to the Schedules tab of the Query Editor. This view contains any schedule information associated with the query.
- Select Delete query to delete the template.
- Select the template name to navigate to the Query Editor where the SQL is pre-populated for editing.
Use the Query Service API to create a template
See the documentation for instructions on how to make a query template using the Query Service API. The details for a newly created query template are contained in the response body.
Next steps
By reading this document, you now have a better understanding of how to create query templates in Query Service. See the UI overview, or the Query Service API guide to learn more about Query Service capabilities.
See the scheduled queries endpoint guide to learn how to schedule queries using the API, or the Query Editor guide for the UI.