Skip to main content

Arrow JS API · schema

Make the table’s contract explicit.

Schema is the ordered description of an Arrow table, record batch, or record. It names each field, declares its DataType and nullability, and carries metadata that should survive serialization.

The Schema model

Describe columns before moving their values.

A schema lets readers, writers, builders, and applications agree on names and types independently of the physical batches that carry the values.

Fields

Ordered Field descriptors for each column

Types

Primitive, nested, temporal, and dictionary types

Nullability

Whether a field may contain null values

Metadata

String key/value annotations and dictionaries

Detailed guide

Schema reference

The sections below document construction, fields, metadata, dictionaries, selection, assignment, and schema compatibility.

info

This page is aligned to Apache Arrow JS v21.x (apache-arrow).

Sequence of arrow Field objects describing columns in a table, batch, or record.

Usage​

import {Schema, Field, Int32, Utf8} from 'apache-arrow';

const schema = new Schema([
new Field('id', new Int32(), false),
new Field('name', new Utf8(), true)
]);

const selected = schema.select(['id']);
console.log(selected.names, schema.names.length);
import {Schema, Field, Int32, Float64} from 'apache-arrow';

const first = new Schema([new Field('a', new Int32())]);
const merged = first.assign(new Schema([new Field('b', new Float64())]));
console.log(merged.names);

Members​

fields: Field[]​

Ordered field list for the schema.

metadata: Map<string, string>​

Optional schema-level metadata.

dictionaries: Map<number, DataType>​

Dictionary id to dictionary type map extracted from nested dictionary fields.

metadataVersion: MetadataVersion​

Schema metadata serialization version.

names: (keyof T)[]​

Column names in schema order.

Methods​

constructor(fields: Field<T[keyof T]>[] = [], metadata: Map<string, string> | null = null, dictionaries: Map<number, DataType> | null = null, metadataVersion: MetadataVersion = MetadataVersion.V4)​

Constructs a schema from fields and optional metadata.

select<K extends keyof T = any>(fieldNames: K[]): Schema<{ [P in K]: T[P] }>​

Returns a new schema containing only selected field names.

selectAt<K extends T = any>(fieldIndices: number[]): Schema<K>​

Returns a new schema containing fields at selected indices.

assign<R extends TypeMap = any>(schema: Schema<R>): Schema<T & R>​

assign<R extends TypeMap = any>(...fields: (Field<R[keyof R]> | Field<R[keyof R]>[])[]): Schema<T & R>​

Merges this schema with another schema or one or more fields and returns a new schema.

toString(): string​

Returns a short schema preview.

[Symbol.toStringTag]: string​

Returns 'Schema'.