Skip to main content
The JSON value decoder stores the whole message body as a single JSON value in a field called __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 source from a Kafka header and the body also has a source key, 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 null have 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 in streamConfigs, then add one transform per column. Each transform reads __value, a column that stores it, a header, the key, or metadata.
  • stream.kafka.metadata.populate is only needed when a column reads a header (__header$<name>) or metadata (__metadata$<name>).
  • Make the column that stores __value a JSON column. You can then query it with JSON_EXTRACT_SCALAR and JSON_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. Set stream.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 __value with jsonPathString instead.
  • A schema column is named __value.
  • A table reads __value but uses a different decoder. No other decoder fills __value.
  • Streams of the same table use different decoders.
  • The table sets schemaConformingTransformerConfig, complexTypeConfig, a custom recordExtractorClass, or jsonFormat set to SQLITE_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 the JSON 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.