Different pipes. One standard.

Type to search this site.

Search runs in your browser against a static index built with this site (Pagefind). Nothing you type is sent to a server.

TransformExperimentalneeds: arrow

std:ndjson-to-arrow #

Converts records to Arrow record batches, refusing lossy values.

For example: hand records to an Arrow-based tool without losing precision.

A pipe is a data processing step with declared inputs and outputs; standard pipes are built into the runner.

Ports #

std:ndjson-to-arrow takes in and produces out.std:ndjson-to-arrowinrecordsoutbatches
std:ndjson-to-arrow takes in and produces out.std:ndjson-to-arrowinrecordsoutbatches
Named ports from the latest published contract. Dashed lines are optional ports.
Ports of std:ndjson-to-arrow
PortDirectionKindRequiredDescription
ininputrecordsyes
outoutputbatchesyes

Parameters #

Parameters of std:ndjson-to-arrow
NameTypeDefaultRequiredDescription
schemaobjectnoneyesArrow schema: {fields: [{name, type, nullable}]}.
batchSizeinteger1024no Minimum 1. Maximum 1000000.

When to use it #

  • The next pipe consumes an Arrow IPC stream (a batches input): convert explicitly, with the schema you state.
  • Catch a value that would not survive the conversion — an integer out of range, a null in a non-nullable column: the run fails with E_FORMAT instead of storing something else.

When to use something else

  • It is available only on runners that advertise the arrow capability, and it never infers a schema. Between pipes that both speak NDJSON no conversion is needed.

How it works #

Only where the runner has Arrow #

std:ndjson-to-arrow and std:arrow-to-ndjson convert between item streams and Arrow IPC streams (application/vnd.apache.arrow.stream). Both declare requires: [arrow]: they exist only on runners that advertise the arrow capability, and a runner that claims conformance to the standard library does not have to. A runner without it rejects the pipeline at validation time with E_UNSUPPORTED — it never substitutes another behaviour. openflange version --capabilities shows what a runner offers.

Exact or refused #

You give the target schema in the Arrow JSON form, {fields: [{name, type, nullable}]}; the pipe never infers one. A value that cannot be preserved exactly fails the run with E_FORMAT:

  • an integer outside the range of its column type, or a decimal that does not fit the declared precision and scale;
  • a null in a non-nullable column;
  • a member the schema does not describe;
  • a timestamp that is not an RFC 3339 string with the column's unit and zone;
  • binary data that is not valid base64 (binary columns are base64 strings in JSON).

An unknown Arrow type in schema is a parameter error (E_PARAM), reported before the run. batchSize (default 1024) sets how many records go into one Arrow record batch.

A tested example #

Nothing here is invented: this is the test “a value that cannot be preserved is refused” from the pipe's own portable test file, which every conformant runner must pass.

Parameters
{
  "schema": {
    "fields": [
      {
        "name": "a",
        "type": "int64",
        "nullable": false
      }
    ]
  }
}
Input: in
{"a":1.5}
Expected output: —

Expected result: the run fails with E_FORMAT. Nothing is written to the outputs.

The same step as a node of a pipeline.yaml:

pipeline.yaml
nodes:
  ndjson-to-arrow:
    pipe: std:ndjson-to-arrow
    inputs:
      in: {from: inputs.in}
    parameters:
      schema: {fields: [{name: "a", type: "int64", nullable: false}]}

Notes from the manifest #

The pipe's manifest, OPENFLANGE.md, carries these notes.

Part of the OpenFlange standard library (std, version 0.1).

The explicit conversion from JSON records to typed Arrow record batches (media type application/vnd.apache.arrow.stream). It is an optional capability (arrow): a runner without it rejects the pipe with E_UNSUPPORTED; check openflange version --capabilities.

schema lists the columns as {fields: [{name, type, nullable}]} (nullable defaults to true); a schema is never inferred. Supported types: int8 … int64, uint8 … uint64, float64, utf8, bool, binary, decimal128(p,s), timestamp[s|ms|us|ns, UTC], date32. Any other type is E_PARAM.

The conversion is exact or it fails — nothing is rounded, truncated or coerced:

type accepted JSON refused (E_FORMAT)
int*, uint* integer literal within the range of the type fractions, exponents (1.0, 1e3), out-of-range integers, strings
float64 a number literal that survives the round trip: the shortest literal of the stored double is the same number (0.1, 1.50, 1e3) literals that would be rounded, e.g. 0.1234567890123456789 or 12345678901234567890123; out-of-range values
utf8 string anything else
bool true / false anything else
binary string holding standard, padded base64 invalid base64
decimal128(p,s) number whose value has at most s fraction digits and fits p digits (1.5, 15e-1, 2e3) more fraction digits, too many digits
timestamp[unit, UTC] RFC 3339 string ending in Z, no finer than the unit other zones or offsets, finer precision, other formats
date32 YYYY-MM-DD string other formats

null or a missing member is accepted only for nullable columns. A member that is not in the schema is an error (it would be lost); so is a non-object item. Rows are grouped into record batches of at most batchSize rows (the bound on this pipe's state); batches are transport units and imply no window boundaries. An empty input still produces a valid stream carrying the schema.

Number literals are normalised by the round trip (1.50 in a float64 column comes back as 1.5); the value is preserved, the spelling is not. Use decimal128 when the scale matters.

Reference #

Maturity
Experimental
Needs the runner capability
arrow
Processing scope
record
Manifest version
0.1.0