Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | batches | yes | |
out | output | records | yes |
Parameters #
This pipe has no parameters.
When to use it #
- A pipe produces an Arrow IPC stream and the next one wants one JSON record per line.
- Keep exact values on the way out:
decimal128and 64-bit integers are written as number literals with full precision, timestamps as RFC 3339 strings.
When to use something else
- It is available only on runners that advertise the
arrowcapability. Input that is not an Arrow IPC stream is refused withE_FORMAT.
How it works #
Only where the runner has Arrow #
std:arrow-to-ndjson and std:ndjson-to-arrow convert between Arrow IPC streams (application/vnd.apache.arrow.stream) and item streams. 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. openflange version --capabilities shows what a runner offers.
What comes out #
One JSON record per line, with nothing rounded on the way:
decimal128and 64-bit integers are written as JSON number literals with full precision;- timestamps become RFC 3339 strings,
date32becomes aYYYY-MM-DDstring; - binary columns become base64 strings.
A value that cannot be preserved exactly, or input that is not an Arrow IPC stream at all, fails the run with E_FORMAT.
A tested example #
Nothing here is invented: this is the test “bytes that are not an Arrow IPC stream are refused” from the pipe's own portable test file, which every conformant runner must pass.
This test sets no parameters.
this is not arrowExpected result: the run fails with E_FORMAT. Nothing is written to the outputs.
The same step as a node of a pipeline.yaml:
nodes:
arrow-to-ndjson:
pipe: std:arrow-to-ndjson
inputs:
in: {from: inputs.in}This input is not plain records. A standalone pipeline.yaml cannot declare the kind of its inputs, so this node belongs in a pipe whose manifest declares the input in with kind batches, or after a node that produces that kind.
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 Arrow record batches (media type
application/vnd.apache.arrow.stream) to JSON records. It is an optional
capability (arrow): a runner without it rejects the pipe with
E_UNSUPPORTED.
Every row becomes one JSON object with the columns in schema order.
Supported column types and their JSON form (the inverse of
std:ndjson-to-arrow):
| Arrow type | JSON |
|---|---|
int8 … int64, uint8 … uint64 |
integer literal, full precision |
float64 |
shortest number literal that round-trips; non-finite values are refused |
utf8 |
string |
bool |
true / false |
binary |
base64 string |
decimal128(p,s) |
number literal with exactly s fraction digits |
timestamp[unit, UTC] |
RFC 3339 string with the unit's fraction digits (0, 3, 6 or 9), Z suffix |
date32 |
YYYY-MM-DD string |
Null values become JSON null. A stream containing any other column type
(nested types, dictionaries, float32, timestamps without the UTC zone …)
is refused with E_UNSUPPORTED rather than converted approximately. A
malformed or empty stream is E_FORMAT, as are two columns with the same
name. State is bounded by one record batch of the input.
Reference #
- Maturity
- Experimental
- Needs the runner capability
arrow- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:ndjson-to-arrow and std:arrow-to-ndjson (capability arrow) in the standard library specification
- Manifest and tests: std/0.1/arrow-to-ndjson in the specification repository