从 Web 加载 DuckDB 宏
维护者: lmangani
安装和加载
INSTALL webmacro FROM community;
LOAD webmacro;
示例
-- Create a DuckDB Scalar or Table macro statement and save it to a gist;
-- Load your remote macro onto your system using the gist url
D SELECT load_macro_from_url('https://gist.githubusercontent.com/lmangani/518215a68e674ac662537d518799b893/raw/5f305480fdd7468f4ecda3686011bab8e8e711bf/bsky.sql') as res;
┌─────────────────────────────────────────┐
│ res │
│ varchar │
├─────────────────────────────────────────┤
│ Successfully loaded macro: search_posts │
└─────────────────────────────────────────┘
-- Use your new macro and have fun:
D SELECT * FROM search_posts('qxip.bsky.social', text := 'quack');
┌──────────────────┬──────────────┬──────────────────────┬───┬─────────┬─────────┬───────┬────────┐
│ author_handle │ display_name │ post_text │ … │ replies │ reposts │ likes │ quotes │
│ varchar │ varchar │ varchar │ │ int64 │ int64 │ int64 │ int64 │
├──────────────────┼──────────────┼──────────────────────┼───┼─────────┼─────────┼───────┼────────┤
│ qxip.bsky.social │ qxip │ This is super cool… │ … │ 1 │ 0 │ 1 │ 0 │
│ qxip.bsky.social │ qxip │ github.com/quacksc… │ … │ 0 │ 1 │ 2 │ 0 │
│ qxip.bsky.social │ qxip │ #DuckDB works grea… │ … │ 2 │ 3 │ 24 │ 0 │
│ qxip.bsky.social │ qxip │ github.com/quacksc… │ … │ 1 │ 0 │ 0 │ 0 │
│ qxip.bsky.social │ qxip │ The latest #Quackp… │ … │ 0 │ 0 │ 2 │ 0 │
│ qxip.bsky.social │ qxip │ The #DuckDB Ecosys… │ … │ 0 │ 0 │ 5 │ 0 │
│ qxip.bsky.social │ qxip │ Ladies and Gents, … │ … │ 1 │ 0 │ 4 │ 0 │
├──────────────────┴──────────────┴──────────────────────┴───┴─────────┴─────────┴───────┴────────┤
│ 7 rows 9 columns (7 shown) │
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
关于 webmacro
HTTP 客户端扩展是实验性的,使用风险自负!
新增函数
function_name (函数名称) | 函数类型 | description (描述) | comment (注释) | examples (示例) |
---|---|---|---|---|
load_macro_from_url (从 URL 加载宏) | 标量 | NULL (空) | NULL (空) |