You can create data products with a dynamic view of data by using customizable parameters and queries. Consumers can specify the parameters, which act as custom queries that return results used to generate the data product. By using customizable queries, data products can be reused more frequently and consumers receive the specific data that they need.
To create a data product that supports customizable queries, you must add and define the necessary parameters and then create an SQL query, which uses the parameters as variables. The consumer subscribes to the data product and indicates the parameters that they need in the subscription details.
- Required roles
- Collaborator roles: Editor
Connect to your remote data by adding a data source connection to your project.
- From the Data Product Hub navigation menu, click Projects > All projects.
- Open or create a project. Then, from the assets page, click New Asset > Connect to a data source.
- Select a data source connection and enter the necessary credentials. Make sure that you use an appropriate set of credentials as these credentials are used to deliver the data product to consumers following a subscription.
- Click Create to validate your data source connection.
Creating a parameter set
Add and define the necessary parameters in a parameter set. You can view the data product request details to create parameters.
- From the assets page, click New Asset > Define reusable sets of parameters.
- Define the following properties for each of the necessary parameters:
- Name: Enter a name for your parameter.
- Type: Indicate what data type the input should be submitted in. Parameters of type
Email
andEncrypted
are not currently supported in customizable queries. - Prompt: Define a prompt that asks users for the parameter.
- Default value: You can pre-populate a property if you are expecting similar responses.
- Click Save to confirm your parameter.
Creating an SQL query with customizable parameters
Define your SQL query that generates your data product by using specified parameters.
- From the projects page, click New asset > Create a dynamic view of data.
- Complete the following fields to define the data asset:
- Name: Enter a name for your data asset.
- Description: Describe the purpose of the query.
- Connection: Select a connection that supports SQL queries. For supported connections, see Delivery methods for connectors.
- Parameter set: Select a parameter set to create queries for.
- Tags (optional): Add tags to make your asset easier to find.
- In the SQL query, connect each parameter with a data value. Ensure that all parameter names in the query match their corresponding names in the parameter set. Designate the parameters by using the following syntax:
'#{parameter_1_name}#'
.
Use the following code sample and graphic as an example for writing an SQL query with parameters:
SELECT * FROM {DATABASE.NAME}
WHERE
{DATABASE.NAME.COLUMN1} = '#{parameter_1_name}#' AND
{DATABASE.NAME.COLUMN2} = '#{parameter_2_name}#';
- Enter sample values for each parameter to generate a data preview. All parameters defined in the query field must contain a sample value. To leave the sample value blank, remove the parameter from the query field.
- Click Create to connect your parameter set with your SQL query. You can verify that your query was validated successfully by locating it in your project's assets page.
Adding a customizable query to a data product
Create your data product by using the projects option.
- From the Data Product Hub navigation menu, click New data product.
- Enter a name for the data product and click the Add from project tile.
- Click Select items and add your query. You can use the advanced filters to locate and add your query quickly and easily from your list of data assets.
- Ensure that your Connection status is verified and create the draft. When your draft is successfully created, a static visualization of your data product is generated and viewable by the consumer.
Next steps
After you create your data product draft, see Completing a data product to finish preparing your data product for publication.
Learn more
Parent topic: Creating a data product