Execute¶
Execution is the phase in which data is fetched from the data source using the adapter. At this stage, you can also apply post-processing operations that your datasource might not cover and custom business logics to your data. Calls payload consists of query
, which contains information about requested parameters and operations.
path: /query/actions/execute
Example of POST
payload:
{
"query": {
...
}
}
Instead, the authenication key that you configure on the crystal Self-Service Console when connecting a new datasource is sent as a request header:
{"X-API-Key": 123}
Query¶
A query is a unified across adapters JSON formatted way of describing what kind of data and how processed one wants to get. Names of the fields can be obtained in the description phase.
Example POST
payload:
{
"from_": {
"datasource_uid": "test_datasource_uid_66",
"collection_uid": "test.customer"
},
"where": "None",
"order_by": "None",
"limit": "None",
"offset": "None",
"aggregations": [
{
"attribute_uri": {
"datasource_uid": "test_datasource_uid_193",
"collection_uid": "test.customer",
"attribute_uid": "points"
},
"alias": "alias_avg",
"function_uri": {
"function_type": "aggregation",
"function_uid": "crystal.topics.data.aggregation.avg",
"function_params": "None"
}
}
],
"groups": [
{
"attribute_uri": {
"datasource_uid": "test_datasource_uid_194",
"collection_uid": "test.customer",
"attribute_uid": "creation"
},
"alias": "alias_date_trunc_month",
"function_uri": {
"function_type": "group_by",
"function_uid": "crystal.topics.data.group-by.date-trunc-month",
"function_params": "None"
}
}
]
}
This request asks for average points grouped by the month of customer creation.
Example response payload:
{
"records": [
{
"alias_date_trunc_month": "2019-11-01T00:00:00",
"alias_avg": 75
},
{
"alias_date_trunc_month": "2019-08-01T00:00:00",
"alias_avg": 64
},
{
"alias_date_trunc_month": "2019-05-01T00:00:00",
"alias_avg": 1
},
{
"alias_date_trunc_month": "2020-02-01T00:00:00",
"alias_avg": 66
},
{
"alias_date_trunc_month": "2020-03-01T00:00:00",
"alias_avg": 55
}
]
}