-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
Description
Rather than trying to stuff it into rarely-used config options like aggregateFunction and valueField, we could just allow an "advanced" option/escape hatch, where you literally pass SQL. This would of course have to be limited to the Carto provider as services like Socrata, CKAN, DKAN don't support SQL queries (as far as I know).
The tricky part is injecting the global filters into the user's SQL string. A couple options so far:
- Pass the filter object, with a method to convert it to a WHERE clause, to the SQL configuration "callback", e.g.:
{
"title": "Crime incidents",
...
"sql": function (filters) {
// filtersObj is the AST, in case you need to manipulate it
return `select * from foo where 1 and ${filters.toString()}`
}
}- Use the user's SQL as a nested query (
select * from (select from ...) where <global filters>)
The 2nd option probably makes more sense if we only need it for carto, but the 1st option is more likely to fit into other providers.