__value. It doesn’t split the body into one field per top-level key, so you choose every column explicitly with ingestion transforms.
Class
ai.startree.pinot.plugin.inputformat.json.JsonValueMessageDecoder
When to use it
Use it when the message body isn’t designed around your table schema. The standard JSON decoder maps each top-level key to the column with the same name, which causes two problems:- Body keys overwrite other columns. If you fill a column such as
sourcefrom a Kafka header and the body also has asourcekey, the column holds the body’s value. A transform doesn’t run on a column that already has a value, so the header value is lost. - Messages that aren’t JSON objects are dropped. Strings, numbers, booleans, arrays and
nullhave no keys to split, so the row is skipped along with its headers.
A message must be exactly one JSON value. Plain text, trailing content, and empty or truncated messages are rejected like any malformed message, and consumption continues.
Configuration example
Set the decoder instreamConfigs, then add one transform per column. Each transform reads __value, a column that stores it, a header, the key, or metadata.
stream.kafka.metadata.populateis only needed when a column reads a header (__header$<name>) or metadata (__metadata$<name>).- Make the column that stores
__valueaJSONcolumn. You can then query it withJSON_EXTRACT_SCALARandJSON_MATCH, add a JSON index, and add derived columns later. A segment reload fills new derived columns from the stored value.
Message formats
The decoder reads text JSON by default. Setstream.kafka.decoder.prop.jsonFormat for other encodings:
SQLITE_JSONB isn’t supported.
Querying the stored value
Table config validation
StarTree checks the table config when you create or update the table, and rejects it if a column would be left empty or read the wrong data:- A schema column has no transform.
- A transform, filter or ingestion aggregation reads a top-level body key such as
state. Read it from__valuewithjsonPathStringinstead. - A schema column is named
__value. - A table reads
__valuebut uses a different decoder. No other decoder fills__value. - Streams of the same table use different decoders.
- The table sets
schemaConformingTransformerConfig,complexTypeConfig, a customrecordExtractorClass, orjsonFormatset toSQLITE_JSONB.
Performance
Decoding takes longer than with the standard JSON decoder because each message is parsed, written back as JSON text, then parsed again by theJSON column. In StarTree’s tests, a 142-byte message took about 850 ns against about 525 ns, and a 100 KB message about 535 µs against about 430 µs.
