Skip to content

DuckDB Extension

WebMacro

Load DuckDB SQL macros from an HTTP URL. Share a macro definition across sessions and pin its source to a reviewed revision.

37,613
extension loads · last 90 days
On this page

Share SQL helpers through a URL

A DuckDB macro packages a reusable SQL expression or query. WebMacro loads a macro definition from an HTTP URL and registers it in the current session, allowing several notebooks or applications to use the same definition.

Use it for shared SQL helpers that you maintain in a repository or another HTTP host. Pin the URL to a reviewed revision when the definition needs to stay stable. The loaded content becomes executable SQL in your session, so choose a source you control or trust.

Example

Load a macro from a URL and use it

Load a macro definition from a URL, then call it like any other DuckDB macro.

Run this example in the DuckDB CLI or a native client.

SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
  WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL webmacro FROM query_farm;
LOAD webmacro FROM query_farm;

-- Pull a macro definition from a URL you control
SELECT load_macro_from_url(
  'https://raw.githubusercontent.com/Query-farm/sql-macros/main/macros/search_posts.sql'
) AS res;

-- Use it like any other DuckDB macro
SELECT * FROM search_posts('alice.example.com', text := 'quack');

The downloaded text must be a single CREATE MACRO statement, and it runs in your session. Use a source you control or trust and pin a reviewed revision.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Configuration
webmacro_allow_http Object type: Setting Allow load_macro_from_url to fetch plain http:// URLs.
webmacro_max_response_size Object type: Setting Largest response, in bytes, that load_macro_from_url will accept
Loading
load_macro_from_url() Object type: Scalar function Fetch the URL, check that the response body is a macro definition, create the macro, and return Successfully loaded macro: <name>.

API Reference

Function Reference

Configuration

Settings

Configure the webmacro extension behavior using these settings.

webmacro_allow_http

Default Value: false

webmacro_max_response_size

Default Value: 1048576

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Experimental
Software License MIT
Pricing Free
Written In C++
Source Available Yes
View on GitHub
Usage
37,613
loads · last 90 days

Platforms

DuckDB 2.0.0

  • Linux x86_64aarch64
  • Linux (musl) Not available
  • macOS Apple Silicon
  • Windows x86_64
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 17.66 MB
Linux aarch64 15.62 MB
macOS Apple Silicon 13.54 MB
Windows x86_64 12.17 MB

Compressed download sizes for the release shown above.

DuckDB & Haybarn

Release calendar
  • DuckDB v2.0.0 Query.Farm repository Supported

Browser examples use Haybarn-Wasm 2.0.0-rc12.

Checked .

Learn and explore

Tutorials and articles

Writing about WebMacro: how it works, what changed, and why.