Blueprints

Run a SQL query with DuckDB on MotherDuck and get the result as a CSV file

Source

yaml
id: motherduck
namespace: company.team
tasks:
  - id: query
    type: io.kestra.plugin.jdbc.duckdb.Query
    sql: |
      SELECT by, COUNT(*) as nr_comments 
      FROM sample_data.hn.hacker_news
      GROUP BY by
      ORDER BY nr_comments DESC;
    fetchType: STORE
  - id: csv
    type: io.kestra.plugin.serdes.csv.IonToCsv
    from: "{{ outputs.query.uri }}"
pluginDefaults:
  - type: io.kestra.plugin.jdbc.duckdb.Query
    values:
      url: jdbc:duckdb:md:my_db?motherduck_token={{ secret('MOTHERDUCK_TOKEN') }}
      timeZoneId: Europe/Berlin

About this blueprint

SQL DuckDB

This flow demonstrates how you can query data stored on MotherDuck using DuckDB. The IonToCsv returns the output as a CSV file which you can download from the Execution page.

Query

Ion To Csv

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra