databricks-sdk-py
databricks-sdk-py copied to clipboard
Add support for `query_plan` for `CHART` type visualization
Description
When creating generic CHART type viz's, the JSON on the wire from the browser to the service contains the query_plan element, next to the options element. The SDK right now does not support it, so we cannot generate for example Pie charts etc.
Reproduction
See https://github.com/databrickslabs/ucx/pull/388 for an attempt to implement a Pie chart. The error is:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Users/lars.george/projects/work/databricks/ucx/src/databricks/labs/ucx/install.py", line 563, in <module>
installer.run()
File "/Users/lars.george/projects/work/databricks/ucx/src/databricks/labs/ucx/install.py", line 78, in run
self._run_configured()
File "/Users/lars.george/projects/work/databricks/ucx/src/databricks/labs/ucx/install.py", line 81, in _run_configured
self._create_dashboards()
File "/Users/lars.george/projects/work/databricks/ucx/src/databricks/labs/ucx/install.py", line 107, in _create_dashboards
self._dashboards["assessment"] = dash.create_dashboard()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lars.george/projects/work/databricks/ucx/src/databricks/labs/ucx/framework/dashboards.py", line 111, in create_dashboard
self._install_viz(query)
File "/Users/lars.george/projects/work/databricks/ucx/src/databricks/labs/ucx/framework/dashboards.py", line 232, in _install_viz
viz = self._ws.query_visualizations.create(self._state[query.query_key], **viz_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: QueryVisualizationsAPI.create() got an unexpected keyword argument 'query_plan'
Expected behavior
The required query_plan element should be supported.
Example wire JSON:
{
"id": "bb948860-94c5-4747-bc2e-4f34095ee00b",
"type": "CHART",
"name": "Pie 1",
"description": "",
"options": {
"version": 2,
"globalSeriesType": "pie",
"sortX": true,
"sortY": true,
"legend": {
"traceorder": "normal"
},
"xAxis": {
"type": "-",
"labels": {
"enabled": true
}
},
"yAxis": [
{
"type": "-"
},
{
"type": "-",
"opposite": true
}
],
"alignYAxesAtZero": true,
"error_y": {
"type": "data",
"visible": true
},
"series": {
"stacking": null,
"error_y": {
"type": "data",
"visible": true
}
},
"seriesOptions": {
"tables": {
"yAxis": 0,
"type": "pie"
},
"views": {
"yAxis": 0,
"type": "pie"
},
"dbfs_root": {
"yAxis": 0,
"type": "pie"
},
"delta_tables": {
"yAxis": 0,
"type": "pie"
}
},
"valuesOptions": {},
"direction": {
"type": "counterclockwise"
},
"sizemode": "diameter",
"coefficient": 1,
"numberFormat": "0,0[.]00000",
"percentFormat": "0[.]00%",
"textFormat": "",
"missingValuesAsZero": true,
"useAggregationsUi": true,
"swappedAxes": false,
"dateTimeFormat": "YYYY-MM-DD HH:mm:ss.SSS",
"showDataLabels": true,
"columnConfigurationMap": {
"x": {
"column": "database",
"id": "column_89149cfb37"
},
"y": [
{
"id": "column_89149cfb36",
"column": "delta_tables"
}
]
},
"isAggregationOn": false
},
"updated_at": "2023-10-05T10:56:58Z",
"created_at": "2023-10-05T10:56:58Z",
"query_plan": {
"selects": [
{
"column": "database"
},
{
"column": "delta_tables"
}
]
}
}