Skip to content

row

const row: {
getBinary: Uint8Array<ArrayBufferLike> | null;
getBoolean: boolean | null;
getDate: Date | null;
getDouble: number | null;
getInt: number | null;
getLong: bigint | null;
getString: string | null;
};

Defined in: types/row.ts:74

Typed runtime accessors for Row values. Each getter checks the column exists and the value matches the expected JavaScript type. Returns null when the value is null. Throws InvalidInputError on a type mismatch or missing column.

Use when the schema isn’t known at compile time. The alternative, df.as<Schema>().collect(), gives full compile-time typing instead. Matches the Scala Row.getInt, getLong, and getAs[T] pattern.

getBinary(r, col): Uint8Array<ArrayBufferLike> | null;

Spark BinaryType.

Parameter Type
r Row
col string

Uint8Array<ArrayBufferLike> | null

getBoolean(r, col): boolean | null;

Spark BooleanType.

Parameter Type
r Row
col string

boolean | null

getDate(r, col): Date | null;

Spark DateType / TimestampType.

Parameter Type
r Row
col string

Date | null

getDouble(r, col): number | null;

Spark DoubleType / FloatType.

Parameter Type
r Row
col string

number | null

getInt(r, col): number | null;

Spark IntegerType / ShortType / ByteType.

Parameter Type
r Row
col string

number | null

getLong(r, col): bigint | null;

Spark LongType (decoded as bigint to preserve 64-bit precision).

Parameter Type
r Row
col string

bigint | null

getString(r, col): string | null;

Spark StringType. Also covers DecimalType (decoded as string).

Parameter Type
r Row
col string

string | null

import { row } from "@spark-connect-js/core";
const [stats] = await df.collect();
const total = row.getLong(stats, "count"); // bigint | null
const mean = row.getDouble(stats, "average"); // number | null