Skip to content

Row

type Row = Record<string, unknown>;

Defined in: types/row.ts:39

A Row is the JS-native representation of one record returned by a DataFrame action. It maps column names to JavaScript values.

Spark source: Row.scala

When Arrow IPC batches are decoded, each row is materialised as a plain object. This is intentionally kept as a simple Record type because we don’t wrap it in a class because:

  1. Destructuring works naturally: const { name, age } = row;
  2. No prototype overhead for millions of rows.

Values:

  • number for IntegerType, ShortType, ByteType, FloatType, DoubleType
  • bigint for LongType, so the decoded type is stable per column and full 64-bit precision is preserved. Wrap in Number(row.id) when you know the value fits in a JS safe integer. See MDN’s BigInt reference for the language semantics (no float mixing, custom JSON serialization).
  • string for StringType and DecimalType (decimals decode as fixed-point strings honoring scale, e.g. "1.50" for DECIMAL(10,2), since JS has no native arbitrary-precision decimal)
  • boolean for BooleanType
  • Uint8Array for BinaryType
  • Date for DateType and TimestampType. Sub-millisecond precision is lost: Spark’s micro/nano timestamps truncate to ms.
  • Map<K, V> for MapType. Preserves non-string keys, unlike a plain object. Note that JSON.stringify(map) is "{}".
  • object for StructType. Nested rows recurse with the same rules.
  • unknown[] for ArrayType. Recurses with the same rules.
  • null for nullable columns

For compile-time typed access, narrow with df.as<Schema>().collect(). For runtime typed access (schema not known statically), use the row accessor namespace.