Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL yaml FROM community;
LOAD yaml FROM community;
Try it in a temporary SQL session with yaml already loaded. Queries run in this tab; examples using files or services need their own setup.
Using upstream DuckDB? Follow the maintainer’s installation instructions.
Usage example
Query YAML files directly
-- Load the extension
-- Query YAML files directly
SELECT * FROM 'config.yaml';
SELECT * FROM 'data/*.yml' WHERE active = true;
-- Create tables with YAML columns
CREATE TABLE configs(id INTEGER, config YAML);
INSERT INTO configs VALUES (1, E'server: production\nport: 8080\nfeatures: [logging, metrics]');
-- Extract data using YAML functions
SELECT
config ->> '$.server' AS environment, -- Arrow operator
yaml_extract(config, '$.port') AS port,
yaml_value(config, '$.port') AS port_scalar
FROM configs;
-- Analyze YAML structure
SELECT yaml_structure(config) FROM configs;
-- Returns: {"server":"VARCHAR","port":"UBIGINT","features":["VARCHAR"]}
-- Check containment and merge documents
SELECT yaml_contains(config, 'server: production') AS is_prod FROM configs;
SELECT yaml_merge_patch(config, 'debug: true') AS with_debug FROM configs;
-- Convert between YAML and JSON
SELECT yaml_to_json(config) AS json_config FROM configs;
SELECT to_yaml({name: 'John', age: 30}) AS yaml_person;
-- Write query results to YAML
COPY (SELECT * FROM users) TO 'output.yaml' (FORMAT yaml, STYLE block);
Provided by teaguesterling. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
The YAML extension brings comprehensive YAML support to DuckDB, enabling seamless integration of YAML data within SQL queries.
The extension is built using yaml-cpp and follows DuckDB's extension development best practices, ensuring reliable performance and cross-platform compatibility.
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- teaguesterling/duckdb_yaml
- License
- MIT
- Maintainers
- teaguesterling
- Written in
- C++
- Build source
4d9aaffb613d- Build definition
- Community descriptor