SINK()
All functions > METADATA > SINK()
Where a LOGGER or a HOOK writes: the scheme of the DSN names the product. Loggers write cold sinks (files, object stores, stdout://), hooks hot ones (Redis, PostgreSQL, MySQL).
Signatures
Returns: A sink for loggers (cold) or hooks (hot)
SINK( dsn [ KEY key_expression | TABLE table [ KEY ( column, ... ) ] ] [ INDEXED ON field UNIQUE ON field ] [ WITH ( property = value, ... ) ] ) property: FORMAT | COMPRESSION | ROLL_SECONDS | ROLL_MB | MODE | SHAPE | RETENTION | PASSWORD → SINK
| Parameter | Type | Required | Description |
|---|---|---|---|
dsn | VARCHAR | Yes | Cold: s3://bucket/prefix, gs://…, az://…, file:///dir or stdout://; hot: redis://…, postgresql://…, mysql://… |
format | VARCHAR | No | WITH property: 'parquet' (default) or 'jsonl'; stdout:// is 'jsonl' only |
compression | VARCHAR | No | WITH property, Parquet only: 'zstd' (default), 'snappy', 'gzip' or 'none' |
roll_seconds | BIGINT | No | WITH property, 1 to 3600: a file is closed (and uploaded) once this old. Default: featuremeshd's serving.logging.roll_interval (60 s) for objects; file:// jsonl rolls every hour |
roll_mb | BIGINT | No | WITH property, 1 to 1024: a file is closed once this large. Default: featuremeshd's serving.logging.roll_size_mb (64). Each open file is held in memory until uploaded |
mode | VARCHAR | No | WITH property, hot sinks: 'append' (default; the event index: a Redis sorted_set, or a table) or 'latest' (one value per key) |
shape | VARCHAR | No | WITH property, Redis: 'string' (default for latest) or 'sorted_set' (for append) |
retention | INTERVAL | No | WITH property, hot sinks: a row is removed once its time (the INDEXED ON field, else request_time) is older than the store's clock minus this |
watermark_key | VARCHAR | No | WITH property: materialized views only |
password | VARCHAR | No | WITH property, hot sinks and queues: the store's password, in place of the DSN's, written as SECRET(...) so the registry never holds it |
key | VARCHAR | No | Redis: the key, an expression over the hook statement's inputs and output; a hash tag ({…}) around its key part |
table | VARCHAR | No | PostgreSQL, MySQL: the table, created by the user |
key_columns | ARRAY<VARCHAR> | No | PostgreSQL, MySQL: the key columns, from the statement's inputs or output fields |
indexed_on | VARCHAR | No | The event index: the time field members are scored (or rows indexed) by |
unique_on | VARCHAR | No | The event index: the field identifying an event; a replay replaces its member |
See also
Examples
Persist a sink that writes JSON lines files
FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.LOGGING.ML_LOGS AS SINK('file:///tmp/featuremesh_logs' WITH (FORMAT = 'jsonl'));Result
| feature_name VARCHAR | status VARCHAR | message VARCHAR |
|---|---|---|
| FM.TUTORIALS.LOGGING.ML_LOGS | CREATED | Feature created as not exists |