Loading functions in the WebMacro DuckDB extension
Function category
Loading
1 functionFetch a SQL macro definition from an HTTP(S) URL and register it in the current DuckDB session. The whole extension is one function — point it at a URL that returns `CREATE MACRO ...` SQL.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
url
|
Type
VARCHAR
|
Mode Positional |
Description
HTTP or HTTPS URL whose response body is a SQL CREATE MACRO statement (scalar or table macro). Redirects are followed; any non-200 response raises an error.
|
Description
Fetch the URL, validate that the response body is a macro definition, register the macro in the current DuckDB connection, and return Successfully loaded macro: <name>. The macro is then callable by name like any other DuckDB macro until the session ends.
The response body must contain one of CREATE MACRO, CREATE OR REPLACE MACRO, CREATE TEMP MACRO, CREATE TEMPORARY MACRO, CREATE OR REPLACE TEMP MACRO, or CREATE OR REPLACE TEMPORARY MACRO. The fetched SQL is rejected if it contains other dangerous statements (e.g. DROP, DELETE, ALTER, ATTACH, EXECUTE) — but that filter is a substring check, not a parser, so the security model is trust the URL, not trust the filter. See the Trust model section.
SELECT load_macro_from_url(
'https://raw.githubusercontent.com/your-org/sql-macros/main/search_posts.sql'
) AS res;
-- 'Successfully loaded macro: search_posts'
SELECT load_macro_from_url('https://quacks.cc/r/search_posts');
SELECT *
FROM search_posts('qxip.bsky.social', text := 'quack');
SELECT load_macro_from_url(url) AS status
FROM (VALUES
('https://raw.githubusercontent.com/your-org/sql-macros/main/search_posts.sql'),
('https://raw.githubusercontent.com/your-org/sql-macros/main/normalize_handle.sql'),
('https://raw.githubusercontent.com/your-org/sql-macros/main/active_users.sql')
) AS macros(url);