Creating ExecutionJobs for query using Data Contextualization¶
The Data Query Service creates executionJobs for dynamic queries. This document describes how to create executionJobs.
Note
- Data Contextualization is only applicable for Local Private Cloud.
- Business query is not applicable for Private Cloud.
Prerequisites¶
- Data Contextualization provisioned to the tenant.
- A Data Contextualization role: either admin or technical user credentials.
- ExecutionJob can be created only for existing dynamic query.
POST api/sdi/v4/queries/{id}/executionJobs
Define the following header:
Authorization: {Bearer Token}
Content-Type: application/json
Request example¶
{
"description": "Running query with sample alias and parameters",
"parameters": [
{
"paramName": "column1",
"paramValue": "'abc'"
}
],
"aliases": [
{
"attributeName": "column1",
"aliasValue": "abc"
}
]
}
Note
- Parameters and/or aliases must be provided in the request, both cannot be null or empty.
- Placeholder name should be same as column name. For details, refer examples section.
Request attribute details¶
Parameter | Description | Type | Mandatory | Default value |
---|---|---|---|---|
description | More details about executionJob | String | No | null |
paramName | Placeholder name (same as column name) provided in query | String | No | null |
paramValue | User provided value. Datatype of value should be same as column | Any | No | null |
attributeName | Column name from select list | String | no | null |
aliasValue | Display name for column value | String | no | null |
id (path param) | Id of existing dynamic query | String | yes |
Examples¶
-
Query with parameter of type String
- Dynamic Query:
SELECT sditest_vehicle.vin FROM sditest_vehicle WHERE sditest_vehicle.vin = :"sditest_vehicle.vin" AND sditest_vehicle.def = 'BMW'
- Placeholders used:
sditest_vehicle.vin
- Column name:
sditest_vehicle.vin
- Column data type:
String
-
ExecutionJob request:
=:
is used to indicate equal to operator for dynamic parameter. This can be replaced with>:
for greater than equal to operation.{ "description": "Running query with sample alias and parameters", "parameters": [ { "paramName": "sditest_vehicle.vin", "paramValue": "'abc'" } ] }
- Dynamic Query:
-
Query with parameter of type Integer
- Dynamic Query :
SELECT sditest_vehicle.vin FROM sditest_vehicle WHERE sditest_vehicle.vin = :"sditest_vehicle.vin" AND sditest_vehicle.def = 'BMW'
- Placeholders used:
sditest_vehicle.vin
- Column name:
sditest_vehicle.vin
- Column data type:
Integer
-
ExecutionJob request:
{ "description": "Running query with sample alias and parameters", "parameters": [ { "paramName": "sditest_vehicle.vin", "paramValue": 123 } ] }
- Dynamic Query :
-
Query with parameter of type Boolean and alias
- Dynamic Query:
SELECT vin FROM sditest_vehicle WHERE vin = :"vin" AND def = 'BMW'
- Placeholders used:
vin
- Column name:
vin
- Column data type:
Boolean
- Does user want to provide alias:
true
-
ExecutionJob request:
{ "description": "Running query with sample alias and parameters", "parameters": [ { "paramName": "vin", "paramValue": true } ], "aliases": [ { "attributeName": "vin", "aliasValue": "Vin" } ] }
- Dynamic Query:
-
Query with parameter of type Boolean and alias on an aggregate function
- Dynamic Query:
SELECT COUNT(vin) FROM sditest_vehicle WHERE vin = :"vin" AND def = 'BMW'
- Placeholders used:
vin
- Column name:
vin
- Column data type:
Boolean
- Does user want to provide alias:
true
-
ExecutionJob request:
{ "description": "Running query with sample alias and parameters", "parameters": [ { "paramName": "vin", "paramValue": true } ], "aliases": [ { "attributeName": "COUNT(vin)", "aliasValue": "Vin" } ] }
- Dynamic Query:
-
Query with alias
- Dynamic Query:
SELECT distinct vin FROM sditest_vehicle WHERE def = 'BMW'
- Column name:
vin
- Does user want to provide alias:
true
-
ExecutionJob request:
{ "description": "Running query with sample alias and parameters", "aliases": [ { "attributeName": "vin", "aliasValue": "Vin" } ] }
- Dynamic Query:
-
Execution Job with result type
- User can provide a parameter "resultType" in create execution job request to indicate how the results of the query execution job should be returned.
- The possible values for "resultType" are REST and FILE. REST is the default value for this parameter.
- When "resultType" is set to REST, Data Contextualization returns the results of the query execution as a REST API response.
-
When the "resultType" is set to FILE, Data Contextualization stores the results of the query execution as file(s) in the IDL. The "resultDetail" parameter can be used to provide additional inputs to the API such as the desired file type and the results location in the IDL.
{ "description": "Running query with sample alias and parameters", "aliases": [ { "attributeName": "catalog_book_id", "aliasValue": "model" } ], "resultType": "FILE", "resultDetail": { "fileType": "parquet", "location": "/sdiresults/" } }
-
Value provided at the time of job creation takes preference over value given at the time of query creation.
Limitations¶
The values provided in the parameters for dynamic queries should match with datatype of corresponding attribute. Otherwise, the system will not validate this during query execution request.
Except where otherwise noted, content on this site is licensed under the Development License Agreement.