For the complete documentation index, see llms.txt. This page is also available as Markdown.

JSONPATHLONG

This section contains reference documentation for the JSONPATHLONG function.

Extracts the Long value from jsonField based on 'jsonPath', use optional defaultValuefor null or parsing error. This function can only be used in an ingestion transformation function.

Signature

JSONPATHLONG(jsonField, 'jsonPath', [defaultValue])

Arguments
Description

jsonField

An Identifier/Expression contains JSON documents.

'jsonPath'

Follows JsonPath Syntax to read values from JSON documents.

Usage Examples

The usage examples are based on extracting fields from the following JSON document:

{
  "data": {
    "name": "Pete",
    "age": 24,
    "subjects": [
      {
        "name": "maths",
        "homework_grades": [80, 85, 90, 95, 100],
        "grade": "A",
        "score": 90
      },
      {
        "name": "english",
        "homework_grades": [60, 65, 70, 85, 90],
        "grade": "B",
        "score": 70
      }
    ]
  }
}
Expression
Value

JSONPATHLONG(data, '$.age')

24

This function can be used in the table config to extract the age property into the age column, as described below:

Value conversion

JSONPATHLONG converts a matched value to a long as follows:

Matched value
Result

Number

The value's long representation

Boolean

true becomes 1; false becomes 0

TIMESTAMP in materialized input

Epoch milliseconds

DATE in materialized input

Days since the Unix epoch

TIME in materialized input

Milliseconds since midnight

The TIMESTAMP, DATE, and TIME conversions apply when an extractor has already materialized the input as a record object instead of JSON text. Missing or null values, non-numeric values, and conversion errors return defaultValue when it is supplied.

Fast and first-match variants

JSONPATHLONGFORY (experimental)

JSONPATHLONGFORY(jsonField, 'jsonPath', [defaultValue])

JSONPATHLONGFORY evaluates eligible simple scalar paths with Apache Fory and falls back to JSONPATHLONG for unsupported inputs or when Fory is unavailable. The standard Pinot distribution does not ship Fory; the accelerated path requires org.apache.fory:fory-json:1.6.0 and fory-core on the ingestion application's classpath. This experimental function may change or be removed.

Use the opt-in variants below when the path is a simple linear path: $ followed only by .name, ['literal.key'], or [0] segments. For more complex JsonPath features such as wildcards, deep scan (..), filters, unions, slices, negative indexes, or a bare $, Pinot falls back to the existing JSONPATHLONG behavior.

Like JSONPATHLONG, both variants are intended for ingestion transformation functions.

JSONPATHLONGFAST

JSONPATHLONGFAST(jsonField, 'jsonPath', [defaultValue])

JSONPATHLONGFAST resolves supported paths in a single forward pass over the JSON text instead of building the full Jayway DOM first. It keeps the same result as JSONPATHLONG, including the same defaultValue handling, and falls back to the existing implementation when the path is not a simple linear path or the input is not a JSON object or array.

Use JSONPATHLONGFAST when you want lower ingestion CPU cost without changing semantics.

JSONPATHLONGFIRSTMATCH

JSONPATHLONGFIRSTMATCH(jsonField, 'jsonPath', [defaultValue])

JSONPATHLONGFIRSTMATCH uses the same streaming fast path but stops as soon as the addressed field is found. This is usually the fastest option when the field appears early in the JSON document, but it changes behavior for undefined or corrupt input:

  • Duplicate keys resolve to the first occurrence instead of the last one.

  • A document malformed strictly after the addressed field can still return the extracted value.

Use JSONPATHLONGFIRSTMATCH only when the upstream JSON is well-formed and duplicate-free.

Last updated

Was this helpful?