Migrating to new SQL parameters

GC-James
Contributor II

How do I migrate this to the new SQL paramaters?

 

 

%sql
CREATE OR REPLACE TABLE ${environment_name}.${schema_name}.cmip6_max_rainfall_${run_version} AS
SELECT *
FROM read_files('/Volumes/${environment_name}/${schema_name}/pluvial_flood/scratch/gfes_parquets_${run_version}/')

Advika
Community Manager
Community Manager

Hello @GC-James!

To migrate from legacy ${variable} parameters to the new SQL parameter style in Databricks, replace ${variable} with :variable and define those parameters in the UI's "Parameters" section.

Your updated code will look like:

CREATE OR REPLACE TABLE IDENTIFIER(
  :environment_name || '.' || :schema_name || '.' || 'cmip6_max_rainfall_' || :run_version
) AS

SELECT *
FROM read_files(
  '/Volumes/' || :environment_name || '/' || :schema_name || '/pluvial_flood/scratch/gfes_parquets_' || :run_version || '/'
)

 

View solution in original post

GC-James
Contributor II

Thanks for the help on how to change. I must say it seemed better how it was before!