dockerapache-superset

create a dataset in sqllab query editor with parameters in Apache Superset


I'm new to Apache Superset and trying to create a dataset in sqllab query editor with parameters similar to the query below

select * from employee_details where employee_id = {{ employee_id }}

and passing parameter like {"employee_id":3 }

I can run the query without any issue but unable to save the query as a dataset

query running

error from docker log :

superset. exceptions.SupersetGenericDBErrorException: syntax error at or near "{" 2024-06-11 12:18:51 superset_app | LINE 1: ...ELECT * FROM employee_details WHERE employee_id = {{ employe... 2024-06-11 12:18:51 superset_app |

actual requirement create a user report chart based on userid as input parameter(dynamically)


Solution

  • You can't this way. Make a select without the jinja parameter. select * from employee_details. Save it as dataset. Then go to edit the dataset and in the SQL paste the sql with jinja:select * from employee_details where employee_id = {{ employee_id }} Don't forget that the filter name in the dashboard that you will create must have the same name as your variable (employee_id)