cockroachdb / cockroachdb/cockroach

User Defined Functions - Support custom binaries with STDIN/STDOUT

Open
#93,409 4 comments 0 reactions 0 assignees View on GitHub
A-sql-routine C-enhancement O-community T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

It would be extremely useful if we could create our own user defined functions in any language we choose, adding unparalleled flexibility to CRDB. It would provide capabilities like self-run version of Cloudflare's Durable Objects.

Clickhouse does this very well with strong specifications and error handling policies: https://clickhouse.com/docs/en/sql-reference/functions/

Processing through STDIN & STDOUT allows any lanugage to be used as long as the function respects the expect data formats.

Support for SELECTs would be more than enough, as the result of a SELECT could be inserted. For example one function I've always wanted in CRDB is HyperLogLog support. Functions could be made like `hll_merge(IDENTIFIER, NEW_VAL)`, where to update a HLL you UPSERT the result of `hll_merge`, then use a function `hll_count(IDENTIFIER)` to read it.

Some immediate capabilities that could be unlocked are:
1. HyperLogLogs
2. Bloom filters
3. Complex running aggregations (materialized as well)
4. Room/multiplayer session management (e.g. collaborating on a google doc)

Jira issue: CRDB-22319

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.