cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Global INIT script on sql warehouse

noorbasha534
Valued Contributor

Dear all

Is it possible to configure global INIT script on sql warehouse? If not, how can I achieve my below requirement-

For example, this script will have 2 key and value pairs defined : src_catalog_name=ABC, tgt_catalog_name=DEF

I want these 2 be reflected on all sql warehouses when they start. I learnt about SQL warehouse configuration parameters and see there is a pre-defined list and that is not applicable therefor for me.

https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-parameters

appreciate the thoughts.

1 REPLY 1

Isi
Contributor III

hello @noorbasha534 

Unfortunately, in SQL Warehouses, you can't attach an init script that automatically runs when the warehouse starts (similar to what you can do with clusters).

However, there are a few alternatives you can consider:

  1. Session Variables: You can set session variables like src_catalog_name and tgt_catalog_name within the current session. These variables will persist only for the duration of the session and need to be redefined when the session restarts. You can use these variables in your queries during the session. Docs

  2. Widgets: Another option is to use widgets to parameterize your queries. Widgets allow you to create interactive elements in notebooks, which can help you define values dynamically. These are especially useful for dashboards and notebooks where user input is required. Docs

  3. SQL Procedures (Public Preview): If your account has access to the SQL Procedures feature (currently in public preview), you can define procedural logic with variables and dynamic SQL. This feature might offer a more flexible solution, but you'll need to verify if it's available in your account. Docs

So you'll need to manage these variables and parameters manually for each session or query run. 

Hope this helps, ๐Ÿ™‚

Isi

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now