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:ย 

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}/')
1 ACCEPTED SOLUTION

Accepted Solutions

Advika
Databricks Employee
Databricks Employee

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

2 REPLIES 2

Advika
Databricks Employee
Databricks Employee

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 || '/'
)

 

GC-James
Contributor II

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