GitHub user Ruchitha598 added a comment to the discussion: REST API Endpoint for Downloading Superset Charts in CSV/Excel Format
The below JSON represents the full query context for a specific chart. However,
when accessing the chart data through the Superset API, we typically only
receive the form_data portion. Is it possible to reconstruct the queries
section using the details from form_data? Additionally, can the adhoc_filters
from form_data be directly used within the filters field in the queries
parameter? And also, could you please provide an example based on the chart
configuration shared below?
{
"datasource": {
"id": 1,
"type": "table"
},
"force": false,
"queries": [
{
"filters": [],
"extras": {
"time_grain_sqla": "P1D",
"having": "",
"where": "(PROMOTION_DATE >=
DATE_SUB(CURRENT_DATE, CAST(2 AS INTERVAL MONTH))) AND (PROMOTION_DATE <=
CURRENT_DATE)"
},
"applied_time_extras": {},
"columns": [
{
"expressionType": "SQL",
"label": "YEAR",
"sqlExpression": "YEAR"
},
{
"expressionType": "SQL",
"label": "QUARTER",
"sqlExpression": "QUARTER"
},
{
"expressionType": "SQL",
"label": "MONTH",
"sqlExpression": "MONTH"
},
{
"expressionType": "SQL",
"label": "PROMOTION_DATE",
"sqlExpression": "PROMOTION_DATE"
},
{
"expressionType": "SQL",
"label": "CAMPAIGN NAME",
"sqlExpression": "CAMPAIGN_NAME"
}
],
"metrics": [
{
"expressionType": "SQL",
"label": "CONVERSION PERCENTAGE",
"sqlExpression": "round((SUM(DEL_COUNT)
* 100.0 / NULLIF(SUM(PUSHED_COUNT), 0)), 2)"
},
{
"expressionType": "SQL",
"label": "PUSHED",
"sqlExpression": "SUM(PUSHED_COUNT)"
},
{
"expressionType": "SQL",
"label": "DELIVERED",
"sqlExpression": "SUM(DEL_COUNT)"
}
],
"orderby": [
[
{
"aggregate": null,
"column": null,
"datasourceWarning": false,
"expressionType": "SQL",
"hasCustomLabel": false,
"label": "PUSHED",
"optionName": null,
"sqlExpression":
"SUM(PUSHED_COUNT)"
},
false
]
],
"annotation_layers": [],
"row_limit": 1000,
"series_limit": 0,
"series_limit_metric": {
"aggregate": null,
"column": null,
"datasourceWarning": false,
"expressionType": "SQL",
"hasCustomLabel": false,
"label": "PUSHED",
"optionName": null,
"sqlExpression": "SUM(PUSHED_COUNT)"
},
"order_desc": true,
"url_params": {
"form_data_key":
"qahtKstFg1HMxGIeL6auZjI5TFS_cu-fV-zRj9g-bKRekRNwdbs0cRmq1_ulaLpg",
"save_action": "overwrite",
"slice_id": "95"
},
"custom_params": {},
"custom_form_data": {}
}
],
"form_data": {
"datasource": "1__table",
"viz_type": "pivot_table_v2",
"slice_id": 95,
"url_params": {
"form_data_key":
"qahtKstFg1HMxGIeL6auZjI5TFS_cu-fV-zRj9g-bKRekRNwdbs0cRmq1_ulaLpg",
"save_action": "overwrite",
"slice_id": "95"
},
"groupbyColumns": [
{
"expressionType": "SQL",
"label": "YEAR",
"sqlExpression": "YEAR"
},
{
"expressionType": "SQL",
"label": "QUARTER",
"sqlExpression": "QUARTER"
},
{
"expressionType": "SQL",
"label": "MONTH",
"sqlExpression": "MONTH"
},
{
"expressionType": "SQL",
"label": "PROMOTION_DATE",
"sqlExpression": "PROMOTION_DATE"
}
],
"groupbyRows": [
{
"expressionType": "SQL",
"label": "CAMPAIGN NAME",
"sqlExpression": "CAMPAIGN_NAME"
}
],
"time_grain_sqla": "P1D",
"temporal_columns_lookup": {
"PROMOTION_DATE": true
},
"metrics": [
{
"expressionType": "SQL",
"label": "CONVERSION PERCENTAGE",
"sqlExpression": "round((SUM(DEL_COUNT) * 100.0
/ NULLIF(SUM(PUSHED_COUNT), 0)), 2)"
},
{
"expressionType": "SQL",
"label": "PUSHED",
"sqlExpression": "SUM(PUSHED_COUNT)"
},
{
"expressionType": "SQL",
"label": "DELIVERED",
"sqlExpression": "SUM(DEL_COUNT)"
}
],
"metricsLayout": "ROWS",
"adhoc_filters": [
{
"clause": "WHERE",
"comparator": null,
"expressionType": "SQL",
"operator": "TEMPORAL_RANGE",
"sqlExpression": "PROMOTION_DATE >=
DATE_SUB(CURRENT_DATE, CAST(2 AS INTERVAL MONTH))",
"subject": "PROMOTION_DATE"
},
{
"clause": "WHERE",
"comparator": null,
"expressionType": "SQL",
"operator": "TEMPORAL_RANGE",
"sqlExpression": "PROMOTION_DATE <=
CURRENT_DATE",
"subject": "PROMOTION_DATE"
}
],
"row_limit": "1000",
"series_limit_metric": {
"aggregate": null,
"column": null,
"datasourceWarning": false,
"expressionType": "SQL",
"hasCustomLabel": false,
"label": "PUSHED",
"optionName": null,
"sqlExpression": "SUM(PUSHED_COUNT)"
},
"order_desc": true,
"aggregateFunction": "Average",
"rowSubTotals": false,
"colSubTotals": true,
"combineMetric": true,
"valueFormat": "SMART_NUMBER",
"date_format": "smart_date",
"rowOrder": "key_a_to_z",
"colOrder": "key_a_to_z",
"extra_form_data": {},
"force": false,
"result_format": "json",
"result_type": "full"
},
"result_format": "json",
"result_type": "full"
}
GitHub link:
https://github.com/apache/superset/discussions/33574#discussioncomment-13256486
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
