How to replace ${param} by :param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 08:02 PM
Hello,
We previously used ${param} in our SQL queries:
SELECT * FROM json.`${source_path}/file.json`However, this syntax is now deprecated. The recommended approach is to use :param instead.
But when I attempt to replace ${param} with :param, I encounter the below error:
SELECT * FROM json.`:source_path/file.json`java.net.URISyntaxException: Relative path in absolute URI: :source_path/file.json
How can I correctly reference the parameter in this case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 11:56 PM
Hi @ZD
Please try this syntax in Your notebook for SQL:
%sql
declare _my_path = 'some_path';
select _my_path;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 01:33 AM
The question is how to use this declared variable between backticks `_my_path` ?
SELECT * FROM json.`_my_path/file.json`This does not work!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 02:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 02:45 AM
Thank you for the proposed solution. However, this does not meet my business needs as it does not offer a dynamic approach for replacing the base path when having multiple files and formats.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 03:06 AM
Hi @ZD ,
But it does, you can use it in following way. Define 3 parameters:
- file_format
- base_path
- file_name
And then concatenate those parameters inside identifier clause:
SELECT *
FROM identifier(:file_format || :base_path || :file_name)
Or maybe I didn't understand your requirments properly.