Arrow types
On this page
The type factories, the erased facade shapes, and the predicates that discriminate them.
function binary
Section titled “function binary”const binary = (): BinaryType => impl.binary() as unknown as BinaryTypefunction date
Section titled “function date”const date = (unit?: number): Date64Type => impl.date(unit) as unknown as Date64Typefunction dateDay
Section titled “function dateDay”const dateDay = (): Date32Type => impl.dateDay() as unknown as Date32Typefunction dateMillisecond
Section titled “function dateMillisecond”const dateMillisecond = (): Date64Type => impl.dateMillisecond() as unknown as Date64Typefunction decimal
Section titled “function decimal”const decimal = (precision: number, scale: number, bitWidth?: 32 | 64 | 128 | 256): DecimalType =>impl.decimal(precision, scale, bitWidth) as unknown as DecimalTypefunction decimal128
Section titled “function decimal128”const decimal128 = (precision: number, scale: number): DecimalType =>impl.decimal128(precision, scale) as unknown as DecimalTypefunction decimal256
Section titled “function decimal256”const decimal256 = (precision: number, scale: number): DecimalType =>impl.decimal256(precision, scale) as unknown as DecimalTypefunction denseUnion
Section titled “function denseUnion”const denseUnion = (children: readonly (VgiField | VgiDataType)[],typeIds?: number[],): UnionType => impl.denseUnion(children as any, typeIds) as unknown as UnionTypefunction dictionary
Section titled “function dictionary”export function dictionary<V extends VgiDataType>(valueType: V,indexType?: VgiDataType,ordered?: boolean,id?: number,): DictionaryType<V>function duration
Section titled “function duration”export function duration<U extends TUnit = TUnit>(unit?: number): DurationType<U>function durationMicros
Section titled “function durationMicros”const durationMicros = (): DurationType<"us"> =>impl.duration(impl.TimeUnit.MICROSECOND) as unknown as DurationType<"us">function durationMillis
Section titled “function durationMillis”const durationMillis = (): DurationType<"ms"> =>impl.duration(impl.TimeUnit.MILLISECOND) as unknown as DurationType<"ms">function durationNanos
Section titled “function durationNanos”const durationNanos = (): DurationType<"ns"> =>impl.duration(impl.TimeUnit.NANOSECOND) as unknown as DurationType<"ns">function durationSeconds
Section titled “function durationSeconds”const durationSeconds = (): DurationType<"s"> =>impl.duration(impl.TimeUnit.SECOND) as unknown as DurationType<"s">function field
Section titled “function field”export function field<Name extends string, T extends VgiDataType>(name: Name,type: T,nullable?: boolean,metadata?: Map<string, string>,): TypedField<Name, T>Description
field(): preserve the precise name + type so struct() can carry a typed
child tuple. Runtime is the backend field.
function fixedSizeBinary
Section titled “function fixedSizeBinary”const fixedSizeBinary = (byteWidth: number): FixedSizeBinaryType =>impl.fixedSizeBinary(byteWidth) as unknown as FixedSizeBinaryTypefunction fixedSizeList
Section titled “function fixedSizeList”export function fixedSizeList<T extends VgiDataType>(child: TypedField<string, T> | T,listSize: number,): FixedSizeListType<T>function float16
Section titled “function float16”const float16 = (): FloatType => impl.float16() as unknown as FloatTypefunction float64
Section titled “function float64”const float64 = (): FloatType => impl.float64() as unknown as FloatTypefunction int16
Section titled “function int16”const int16 = (): Int16Type => impl.int16() as unknown as Int16Typefunction int64
Section titled “function int64”const int64 = (): Int64Type => impl.int64() as unknown as Int64Typefunction int8
Section titled “function int8”const int8 = (): Int8Type => impl.int8() as unknown as Int8Typefunction interval
Section titled “function interval”const interval = (unit?: number): IntervalType => impl.interval(unit) as unknown as IntervalTypefunction isBatch
Section titled “function isBatch”export function isBatch(x: unknown): x is import(“./types.js”).VgiBatchDescription
Runtime check: does x quack like a VgiBatch? Used at API boundaries
where callers may pass either a batch or a plain column dict. Duck-typed
because arrow-js and flechette use unrelated classes.
function isBinary
Section titled “function isBinary”export function isBinary(t: VgiDataType): booleanfunction isBool
Section titled “function isBool”export function isBool(t: VgiDataType): booleanfunction isDate
Section titled “function isDate”export function isDate(t: VgiDataType): booleanfunction isDecimal
Section titled “function isDecimal”export function isDecimal(t: VgiDataType): booleanfunction isDictionary
Section titled “function isDictionary”export function isDictionary(t: VgiDataType): booleanfunction isDuration
Section titled “function isDuration”export function isDuration(t: VgiDataType): booleanfunction isFixedSizeBinary
Section titled “function isFixedSizeBinary”export function isFixedSizeBinary(t: VgiDataType): booleanfunction isFixedSizeList
Section titled “function isFixedSizeList”export function isFixedSizeList(t: VgiDataType): booleanfunction isFloat
Section titled “function isFloat”export function isFloat(t: VgiDataType): booleanfunction isInterval
Section titled “function isInterval”export function isInterval(t: VgiDataType): booleanfunction isList
Section titled “function isList”export function isList(t: VgiDataType): booleanfunction isNull
Section titled “function isNull”export function isNull(t: VgiDataType): booleanfunction isStruct
Section titled “function isStruct”export function isStruct(t: VgiDataType): booleanfunction isTime
Section titled “function isTime”export function isTime(t: VgiDataType): booleanfunction isTimestamp
Section titled “function isTimestamp”export function isTimestamp(t: VgiDataType): booleanfunction isUnion
Section titled “function isUnion”export function isUnion(t: VgiDataType): booleanfunction isUtf8
Section titled “function isUtf8”export function isUtf8(t: VgiDataType): booleanfunction list
Section titled “function list”export function list<T extends VgiDataType>(child: TypedField<string, T> | T): ListType<T>function map
Section titled “function map”export function map<K extends VgiDataType, V extends VgiDataType>(keyField: TypedField<string, K> | K,valueField: TypedField<string, V> | V,keysSorted?: boolean,): MapType<K, V>function nullType
Section titled “function nullType”const nullType = (): NullDescriptor => impl.nullType() as unknown as NullDescriptorfunction sparseUnion
Section titled “function sparseUnion”const sparseUnion = (children: readonly (VgiField | VgiDataType)[],typeIds?: number[],): UnionType => impl.sparseUnion(children as any, typeIds) as unknown as UnionTypefunction struct
Section titled “function struct”export function struct<const C extends readonly TypedField<string, VgiDataType>[]>(children: C,): StructType<C>interface TaggedUnion
Section titled “interface TaggedUnion”export interface TaggedUnionDescription
A decoded union-typed value: which member is active (tag) and its value.
DuckDB UNION / Arrow union values are tagged — the discriminator (which
member is present) lives in the union’s per-row type code, not in the member
value. A plain scalar read returns only the member value and drops that tag,
so union values are decoded into this wrapper instead: tag is the active
member’s field name (or null for a null union) and value is its decoded
canonical value. Mirrors vgi-python’s vgi.arguments.TaggedUnion.
Fields
tagstring | nullvalueunknown
function time
Section titled “function time”export function time(unit?: number, bitWidth?: 32 | 64): Time32Type<“s” | “ms”> | Time64Type<“us” | “ns”>function timeMicrosecond
Section titled “function timeMicrosecond”const timeMicrosecond = (): Time64Type<“us”> => impl.timeMicrosecond() as unknown as Time64Type<“us”>function timeMillisecond
Section titled “function timeMillisecond”const timeMillisecond = (): Time32Type<“ms”> => impl.timeMillisecond() as unknown as Time32Type<“ms”>function timeNanosecond
Section titled “function timeNanosecond”const timeNanosecond = (): Time64Type<“ns”> => impl.timeNanosecond() as unknown as Time64Type<“ns”>function timeSecond
Section titled “function timeSecond”const timeSecond = (): Time32Type<“s”> => impl.timeSecond() as unknown as Time32Type<“s”>function timestamp
Section titled “function timestamp”export function timestamp<U extends TUnit = TUnit>(unit?: number,timezone?: string | null,): TimestampType<U>Description
timestamp(unit): when called with a literal unit constant the result type carries that unit; with a runtime number it widens to TimestampType<TUnit>.
function timestampMicros
Section titled “function timestampMicros”const timestampMicros = (timezone?: string | null): TimestampType<"us"> =>impl.timestamp(impl.TimeUnit.MICROSECOND, timezone ?? null) as unknown as TimestampType<"us">function timestampMillis
Section titled “function timestampMillis”const timestampMillis = (timezone?: string | null): TimestampType<"ms"> =>impl.timestamp(impl.TimeUnit.MILLISECOND, timezone ?? null) as unknown as TimestampType<"ms">function timestampNanos
Section titled “function timestampNanos”const timestampNanos = (timezone?: string | null): TimestampType<"ns"> =>impl.timestamp(impl.TimeUnit.NANOSECOND, timezone ?? null) as unknown as TimestampType<"ns">function timestampSeconds
Section titled “function timestampSeconds”const timestampSeconds = (timezone?: string | null): TimestampType<"s"> =>impl.timestamp(impl.TimeUnit.SECOND, timezone ?? null) as unknown as TimestampType<"s">function typeSignature
Section titled “function typeSignature”export function typeSignature(t: VgiDataType | null | undefined): stringDescription
Stable structural identity for an Arrow type, usable for equality.
String(type) is NOT usable for this: arrow-js DataTypes are class
instances with a meaningful toString() (“Int64”, “Utf8”, …), while
flechette types are plain object literals that stringify to
“[object Object]”. Comparing with toString() therefore reports every
flechette type as equal to every other, and never equal to a declared
arrow-js type — which collapsed overload resolution to a first-match tie
(type_info(42::BIGINT) picked the INTEGER overload).
Both libraries agree on typeId and on the parameter values; they differ
only on a few property names, so those are read under both spellings. The
output is an opaque key — compare it, don’t display it.
function uint16
Section titled “function uint16”const uint16 = (): Uint16Type => impl.uint16() as unknown as Uint16Typefunction uint32
Section titled “function uint32”const uint32 = (): Uint32Type => impl.uint32() as unknown as Uint32Typefunction uint64
Section titled “function uint64”const uint64 = (): Uint64Type => impl.uint64() as unknown as Uint64Typefunction uint8
Section titled “function uint8”const uint8 = (): Uint8Type => impl.uint8() as unknown as Uint8Typefunction union
Section titled “function union”export function union(mode: number,children: readonly (VgiField | VgiDataType)[],typeIds?: number[],): UnionTypefunction utf8
Section titled “function utf8”const utf8 = (): Utf8Type => impl.utf8() as unknown as Utf8Typeinterface VgiBackendInfo
Section titled “interface VgiBackendInfo”export interface VgiBackendInfoFields
name“arrow-js” | “flechette”
interface VgiBatch
Section titled “interface VgiBatch”export interface VgiBatchFields
schemaVgiSchemanumRowsnumbergetChild(name: string): VgiColumn | nullSee {@link VgiColumn} — this does NOT run the codec.
getChildAt(index: number): VgiColumn | nullSee {@link VgiColumn} — this does NOT run the codec.
interface VgiColumn
Section titled “interface VgiColumn”export interface VgiColumnDescription
Column view over one column of a batch.
The value type is erased by default: arrow-js parameterizes on DataType and
flechette on value type, so the facade cannot name one without picking a
backend. Supply T at the use site — the column’s declared type makes it
known there — and the cast disappears:
const ns = batch.getChildAt(0)! as Iterable<bigint | null>;for (const v of ns) { ... } // v: bigint | nullA type parameter here would read better, but it cannot be had cheaply: both
backends’ native batches are assigned to VgiBatch structurally, and a
concrete get(): unknown does not satisfy a generic get(): T. Adding one
would mean casting at ~25 internal sites to remove one cast in user code.
These are the backend’s own values, not codec output. get() and
iteration return whatever the Arrow implementation stores, which for some
types is not the value the SDK documents:
| Arrow type | here | {@link iterRows } |
|---|---|---|
int64 |
bigint |
bigint (same) |
utf8, float64 |
string, number |
same |
decimal128 |
backend limbs (DecimalBigNum) |
bigint, unscaled |
timestamp[us] |
millisecond number |
microsecond bigint |
date32 |
millisecond number |
Date |
repr: "raw" on a function selects the codec’s representation and has no
effect on this path.
So: reach for getChildAt on integer, float, boolean, string and binary
columns, where it is the cheapest correct thing. For temporal, decimal and
nested types go through {@link iterRows }, which runs the codec.
Fields
typeVgiDataTypelengthnumberget(index: number): unknown[Symbol.iterator](): Iterator<unknown>
type VgiColumnData
Section titled “type VgiColumnData”export type VgiColumnData = unknown;Description
Low-level handle for a single column’s underlying Arrow Data. The shape
differs per backend (arrow-js: a Data instance; flechette: the inner
Column.data[0]-style object), so this is treated opaquely; it’s only
meant to be passed back into facade builders that know how to consume it.
interface VgiDataType
Section titled “interface VgiDataType”export interface VgiDataTypeFields
typeIdVgiTypeId
interface VgiField
Section titled “interface VgiField”export interface VgiFieldFields
namestringtypeVgiDataTypenullablebooleanmetadataMap<string, string>Always defined (possibly empty) so callers don’t need null-checks. Both arrow-js Field.metadata and flechette’s field.metadata are a Map; the field-factory in each backend ensures presence.
interface VgiSchema
Section titled “interface VgiSchema”export interface VgiSchemaFields
fieldsreadonly VgiField[]metadataMap<string, string>
type VgiTypeId
Section titled “type VgiTypeId”export type VgiTypeId = number;Description
Numeric Arrow type discriminator. Values match the Arrow Type enum (Null=1, Int=2, Float=3, Binary=4, Utf8=5, Bool=6, Decimal=7, Date=8, Time=9, Timestamp=10, Interval=11, List=12, Struct=13, Union=14, FixedSizeBinary=15, FixedSizeList=16, Map=17, Duration=18, LargeBinary=19, LargeUtf8=20, Dictionary=-1). Both backends agree.