Skip to main content

Field types

YXDB supports 17 field types. The table below shows how each type maps to Python and PyArrow.

Type reference

YXDB typeFieldInfo.typePyArrow typePython typeNotes
Bool"Bool"pa.bool_()boolSingle bit stored as a byte
Byte"Byte"pa.uint8()intUnsigned 8-bit integer
Int16"Int16"pa.int16()intSigned 16-bit integer
Int32"Int32"pa.int32()intSigned 32-bit integer
Int64"Int64"pa.int64()intSigned 64-bit integer
Float"Float"pa.float32()float32-bit IEEE 754
Double"Double"pa.float64()float64-bit IEEE 754
FixedDecimal"FixedDecimal"pa.float64()floatStored as fixed-point; read as float64
String"String"pa.utf8()strFixed-width narrow string (Latin-1/UTF-8)
WString"WString"pa.utf8()strFixed-width wide string (UTF-16)
V_String"V_String"pa.utf8()strVariable-length narrow string
V_WString"V_WString"pa.utf8()strVariable-length wide string (default for text)
Date"Date"pa.date32()strStored as YYYY-MM-DD
Time"Time"pa.time64("us")strStored as HH:MM:SS
DateTime"DateTime"pa.timestamp("us")strStored as YYYY-MM-DD HH:MM:SS
Blob"Blob"pa.binary()bytesVariable-length binary blob
SpatialObj"SpatialObj"pa.binary()bytesSHP-encoded spatial object (read as raw bytes)

Null values

All 17 types support null values. Nulls are represented as None in Python lists and as null entries in Arrow/Pandas/Polars columns.

Arrow-to-YXDB mapping

When writing from PyArrow (or Pandas/Polars via Arrow), types are mapped automatically:

PyArrow typeYXDB type written
bool_Bool
uint8Byte
int8, int16Int16
int32, uint16Int32
int64, uint32, uint64Int64
float16, float32Float
float64Double
date32, date64Date
time32, time64Time
timestampDateTime
binary, large_binaryBlob
string, large_string, otherV_WString

Schema inference from Python dicts

When writing via write_yxdb without an explicit schema, the type is inferred from the first non-None value in each column:

Python typeYXDB type written
boolBool
intInt64
floatDouble
str or NoneV_WString
bytesBlob
otherV_WString

FixedDecimal

FixedDecimal fields carry size (total digits) and scale (decimal places) in their FieldInfo. When writing, use the FieldInfo class directly to set these:

from openyxdb import FieldInfo

fi = FieldInfo()
fi.name = "price"
fi.type = "FixedDecimal"
fi.size = 10 # total digits
fi.scale = 2 # decimal places

On read, FixedDecimal is returned as float64 in PyArrow and as float in Python. Precision beyond what float64 can represent may be lost.

Spatial objects

SpatialObj fields are returned as raw bytes (SHP-encoded binary). Parsing the SHP geometry is not in scope for this library.