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
ParameterTypeRequiredDescription
dsnVARCHARYesCold: s3://bucket/prefix, gs://…, az://…, file:///dir or stdout://; hot: redis://…, postgresql://…, mysql://…
formatVARCHARNoWITH property: 'parquet' (default) or 'jsonl'; stdout:// is 'jsonl' only
compressionVARCHARNoWITH property, Parquet only: 'zstd' (default), 'snappy', 'gzip' or 'none'
roll_secondsBIGINTNoWITH 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_mbBIGINTNoWITH 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
modeVARCHARNoWITH property, hot sinks: 'append' (default; the event index: a Redis sorted_set, or a table) or 'latest' (one value per key)
shapeVARCHARNoWITH property, Redis: 'string' (default for latest) or 'sorted_set' (for append)
retentionINTERVALNoWITH 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_keyVARCHARNoWITH property: materialized views only
passwordVARCHARNoWITH property, hot sinks and queues: the store's password, in place of the DSN's, written as SECRET(...) so the registry never holds it
keyVARCHARNoRedis: the key, an expression over the hook statement's inputs and output; a hash tag ({…}) around its key part
tableVARCHARNoPostgreSQL, MySQL: the table, created by the user
key_columnsARRAY<VARCHAR>NoPostgreSQL, MySQL: the key columns, from the statement's inputs or output fields
indexed_onVARCHARNoThe event index: the time field members are scored (or rows indexed) by
unique_onVARCHARNoThe 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 VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.LOGGING.ML_LOGSCREATEDFeature created as not exists