BGP AS-path and community helpers in SQL — path length, origin AS, prepend count, membership test, RFC 8092 large-community classification
Maintainer(s):
alitrack
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 |
|---|---|---|---|---|---|
| Linux AMD64 | |||||
| Linux ARM64 | |||||
| macOS AMD64 | |||||
| macOS ARM64 | |||||
| Windows AMD64 | |||||
| Windows ARM64 | |||||
| WebAssembly |
Installing and Loading
INSTALL bgp FROM community;
LOAD bgp;
Example
INSTALL bgp FROM community;
LOAD bgp;
SELECT bgp_path_length('100 200 300'); -- 3
SELECT bgp_origin_asn('100 200 300'); -- 300
SELECT bgp_as_path_prepends('100 100 100 200');-- prepends
SELECT bgp_path_contains('100 200 300', 200); -- true
SELECT bgp_community_parse('65001:100'); -- STRUCT(asn, value)
SELECT bgp_is_large_community('65001:100:5'); -- true
About bgp
bgp — route-policy primitives in SQL
AS-path and community attributes are the workhorse of route-policy analysis. No Python, no bgpkit-parser script, no hand-rolled split.
| Function | Returns | Notes |
|---|---|---|
bgp_path_length(path) |
BIGINT | Number of AS hops |
bgp_origin_asn(path) |
BIGINT | Last AS in the path |
bgp_as_path_prepends(path) |
BIGINT | Prepend count |
bgp_path_contains(path, asn) |
BOOLEAN | Transit membership test |
bgp_community_parse(community) |
STRUCT |
asn + value, NULL if malformed |
bgp_is_large_community(community) |
BOOLEAN | RFC 8092 a:b:c form |
→ GitHub
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| bgp_as_path_prepends | scalar | NULL | NULL | |
| bgp_community_parse | scalar | NULL | NULL | |
| bgp_is_large_community | scalar | NULL | NULL | |
| bgp_origin_asn | scalar | NULL | NULL | |
| bgp_path_contains | scalar | NULL | NULL | |
| bgp_path_length | scalar | NULL | NULL |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases | typed_value |
|---|---|---|---|---|---|
| temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |
© 2026 DuckDB Foundation, Amsterdam NL