CartoDB / CartoDB-SQL-API

CartoDB SQL API
BSD 3-Clause "New" or "Revised" License
63 stars 64 forks source link

Make batch queries usable with regular API keys #621

Open jgoizueta opened 5 years ago

jgoizueta commented 5 years ago

Batch queries can only be used with the master key. This probably was done to facilitate the primary original use of batch queries to execute camshaft analyses, which require access to some internal tables, and the creation of new cache tables which wasn't possible with non-master keys at the time.

These restrictions shouldn't be a problem now: camshaft/Builder will always use master keys to execute queries, and api keys currently allow the creation of tables.

Now, batch queries are very useful for some Dataset operations performed in CartoFrames, because they allow lengthy operations such as data uploads or some analyses that would exceed regular timeouts. But this forces the users to use master keys to be able to perform such operations. This is a serious limitations, since many applications of cartoframes and notebooks would benefit of being able to work with ad hoc API keys.

So it would be valuable to remove the restriction of requiring master keys for batch queries.

cc/ @dgaubert

dgaubert commented 5 years ago

This probably was done to facilitate the primary original use of batch queries to execute camshaft analyses.

It was the other way around. While we were implementing regular api-keys we decided to limit batch queries to be only used by master api-keys for the reasons that @jgoizueta mentioned above.

While Builder and embed (named) maps keep using master api-key internally, I guess we can remove the current restriction to create batch queries and open to regular api-keys as well. In any case, we need to double-check it.

For that, we need to modify job creation and be able to store for the job the database credentials of the regular/master api-key. Currently, we are using master api-key always. See: https://github.com/CartoDB/CartoDB-SQL-API/blob/4.0.0/app/controllers/job_controller.js#L127-L135