I'm currently dealing with Looker's API.
My code aims to extract a query from a look by using the Looker's API. I want my function to download the look and apply filters as desired by the user. However, I also want to ensure that if a user makes a request for a specific look, the column order and column names are maintained. It seems that the API does not provide a way to perform all these tasks within a single API function.
Is there any way to make this easily crafted?
a) Request a look
b) Apply filters if needed
c) Maintain visualization configuration.
Hi @lee942024, thank you for posting!
There's a couple of resources I wanted to share that I hope may be helpful. On the Looker Developer Portal, there's an example workflow of downloading a dashboard to a PDF, which includes setting the filters (https://developers.looker.com/api/tutorials/generating-pdfs).
I believe that you can use this example, and instead of create_dashboard_render_task you can use create_look_render_task.Here is the reference doc for create_look_render_task: https://cloud.google.com/looker/docs/reference/looker-api/latest/methods/RenderTask/create_look_rend...It includes links to examples in Ruby and Python that might be helpful as well!
Thanks for your replay!
However this is not what I'm looking for. I need the 'csv' file not the rendered/pdf version of my look.
I'm trying by using look and run_look, but both of them cannot perform all of what I want. By using look, I can get the query underneath my look and then perform run_inline_query() and set up whatever filters I want on that new query. Sadly, I lose the visualization configuration and that's my roadblock.
On the other side, I see I can perform run_look() with vis_config=True but this method cannot set new filters.
Do you know some work around?
Thanks for the additional details! It makes sense that filters can't be applied even with the API -- if you try to download a Look via CSV in the Looker UI, there is also no option to update filters:
The filters need to be applied to the query and run beforehand, like you mentioned with the run_inline_query() method you are using.
I'm not aware of any workarounds, other than applying the filter before the Look is downloaded with vis settings applied. I can definitely see why it would be useful to change the filter while you download! If you are able, it would be super helpful to our product team if you filed a product idea or feature request for this capability. Here are directions on how to do so in the Looker platform: https://www.googlecloudcommunity.com/gc/The-Kitchen-Table/Feature-Requests-How-your-feedback-makes-L...
Alright thanks!