Skip to content
DuckDB community extension

fire_duck_ext

Query Google Cloud Firestore directly from DuckDB using SQL

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL fire_duck_ext FROM community;
LOAD fire_duck_ext FROM community;

Try it in a temporary SQL session with fire_duck_ext 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.

02 / QUERY

Usage example

Authenticate with a service account key file (see the README for API-key

SQL
-- Authenticate with a service account key file (see the README for API-key
-- and Firebase-user auth, including browser-safe authentication)
CREATE SECRET my_firestore (
    TYPE firestore,
    PROJECT_ID 'my-gcp-project',
    SERVICE_ACCOUNT_JSON '/path/to/service-account.json'
);

-- Read documents
SELECT * FROM firestore_scan('users');

-- Filter with SQL
SELECT __document_id, name, email
FROM firestore_scan('users')
WHERE status = 'active';

-- Update a document
CALL firestore_update('users', 'user123', 'status', 'verified');

-- Insert documents from a subquery
CALL firestore_insert('users', (SELECT name, age FROM read_csv('new_users.csv')));

Provided by BorisBesky. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

fire_duck_ext lets you work with Google Cloud Firestore directly from DuckDB using SQL. Read with firestore_scan(), which also covers collection-group queries (firestore_scan('~collection')) and subcollection-ID discovery (firestore_scan('collection/doc_id')). Write with firestore_insert(), firestore_update(), firestore_delete(), their batch counterparts (firestore_update_batch(), firestore_delete_batch()), and the array-transform functions firestore_array_union(), firestore_array_remove(), and firestore_array_append(). Every function documents itself in duckdb_functions() with a description, parameter names, and an example.

WHERE filters, SQL ORDER BY / LIMIT, the column projection, and a bare COUNT(*) are pushed down to Firestore where possible. A query then transfers only what it uses: matching rows, selected fields, and for a count, no documents at all. Firestore orders differently from SQL, so an ORDER BY is only sent when the sampled documents say the two agree; otherwise DuckDB sorts and the reason is logged.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
BorisBesky/fire_duck_ext
License
MIT
Maintainers
BorisBesky
Written in
C++
Build source
c59ff962087d
Build definition
Community descriptor