Question

How to change project name for Google Big Query SQl's dynamically based on the instance

  • 19 June 2017
  • 4 replies
  • 659 views

Userlevel 2

Hi,


I am using Looker with Google Big Query and wanted to know is there any way at teh connection level (which I don’t found) or at the LookML level that allows to change project name dynamically for the SQL in Dev vs Prod instance (which will not require us to manually changed complete path for the view/table in SQL before moving code to production instnace. I know I can setup default porject at the connection level but team decided to use different project as a default project for proper usage tracking and that will not have any view/tables.


I tried using templated filter where default project name in from clause pass from the filter but as templated filter only allows strings, name comes with ‘’ that will not validate the GBQ standard SQL table/view reference.


Let me know if have any other setting or options that I can try to achieve same scenario.


Thanks,

Kunal


4 replies

Hi Kunal -


No, this isn’t possible within Looker.


Cheers,

Dave

Userlevel 1

Kunal,


You should be able to accomplish this with User Attributes as described here:




You would set the user attribute, let’s call it “BQ Project,” to one value on the Dev server and to a different value on the Prod server (one time), and Looker will dynamically query the correct table from there (without having to change LookML for each deployment)

Userlevel 6
Badge

Another way to solve this is to use the new labs feature ‘project import’.


You can make a project with a single file that only includes the connection and have the contents of that file be different on the production server and the dev server.




In your regular LookML project, instead of a



connection “bigquery”



You would have an include statement that includes a file from the ‘connection_proj’ (a project you make on both the dev and production servers).



include ‘/connection_proj/connection.view’





the project conection_proj would be different for each server.


in the dev server you would make the file ‘connection.view’ contain



connection.view: “bigquery_dev”



and in the production server the file ‘connection.view’ would contain:



connection.view: “bigquery”



To confirm: the queries would not specify the project in their SQL, and so the project would be specified by the connection.


…and for that reason, we couldn’t use this approach to arbitrarily insert some parameterized text into the LookML files (such as changing the dataset, or adding _develop to every table name)?

Reply