microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.54k stars 898 forks source link

Notebook Request: Support For Injectable Parameters using SQL Kernel #18709

Open datawakes opened 2 years ago

datawakes commented 2 years ago

This video illustrates Notebook Parameters using the PowerShell or Python Kernel: How to Parameterize Notebooks for Automation in Azure Data Studio

Similar functionality while using the SQL Kernel would be extremely helpful. For example, given the following input parameters:

$DB_1 = WWI_PROD (could change parameter to WWI_DEV or WWI_TEST, etc.)
$DB_2 = REF_PROD (could change parameter to REF_DEV or REF_TEST, etc.)
$STR_VAL = some string
$INT_VAL = 22.3

This sample query's parameters would be substituted:

select st.val1
     , ot.val2
from   $WWI.dbo.some_table  st
join   $REF.dbo.lookup_table ot
on     st.lkp_key = ot.lkp_key
where  st.val1 = '$STR_VAL'
and    ot.val2 = $NUM_VAL
;

And would be executed in the Notebook as:

select st.val1
     , ot.val2
from   WWI_PROD.dbo.some_table  st
join   REF_PROD.dbo.lookup_table ot
on     st.lkp_key = ot.lkp_key
where  st.val1 = 'some string'
and    ot.val2 = 22.3
;

If multiple databases, representing different promotion paths, are on the same server, this allows for a consistent way to execute the same Notebook in Dev, Test or Prod.

bronthulke commented 4 months ago

Is there an appropriate why for us to put our support for a change? I would love to see this feature.