Skip to main content

Data conversion

Keep the table shape explicit as data moves.

The table and Arrow converters bridge native Apache Arrow tables and loaders.gl row, columnar, and GeoJSON tables.

Shape is part of the contract

Convert at the boundary, not by accident.

A native Arrow table, a columnar table, and an array of row objects can all describe the same records. The converters make the transition deliberate.

Raw Arrow

shape: 'arrow' for Apache Arrow JS tables

Arrow output

shape: 'arrow' returns a native table

Other shapes

Rows, columnar tables, and GeoJSON-like tables

Use it for

Normalization before rendering, scanning, or writing

These converters move between loaders.gl row, columnar, and GeoJSON table shapes and native Apache Arrow tables.

Detailed guide

Converter details

The sections below document the two converter families and their supported shape mappings.

TableConverter​

FieldValue
Package@loaders.gl/core/schema-utils
id'table'
from'object-row-table', 'array-row-table', 'columnar-table', 'arrow'
to'object-row-table', 'array-row-table', 'columnar-table', 'arrow'
DetectionRecognizes native tables and reads input.shape on loaders.gl table wrappers
Typical useConvert between native Arrow and loaders.gl row or column tables

TableConverter can convert native Arrow directly to row or column tables and back.

ArrowConverter​

FieldValue
Package@loaders.gl/tables/arrow
id'arrow'
from'arrow', 'object-row-table', 'array-row-table', 'columnar-table', 'geojson-table'
to'arrow', 'object-row-table', 'array-row-table', 'columnar-table', 'geojson-table'
DetectionTreats raw Apache Arrow Table instances as 'arrow'
Typical useConvert between native Arrow and row, columnar, or GeoJSON tables

Shape Mapping​

ShapeMeaning
'arrow'Raw Apache Arrow Table
'object-row-table'Array of row objects
'array-row-table'Array of row arrays
'columnar-table'Column-oriented loaders.gl wrapper
'geojson-table'loaders.gl table wrapper specialized for GeoJSON-like rows

Common Pattern​

import {convert, TableConverter} from '@loaders.gl/core/schema-utils';
const objectRows = convert(arrowTable, 'object-row-table', TableConverter);
const rawArrow = convert(objectRows, 'arrow', TableConverter);

When To Stop At Arrow​

If your downstream consumer already speaks Arrow, stop at 'arrow'.

If your downstream code wants loaders.gl table helpers or a normalized wrapper shape, continue through TableConverter.