ArpePGSQL — Data types
How PostgreSQL types map to Apache Arrow on the fetch (read) path, and how Arrow types map back to PostgreSQL on the ingest/bind (write) path.
Both directions use PostgreSQL's binary formats, so there is no text round-trip
for the common types. The headline case is NUMERIC, mapped straight to a
decimal128/decimal256 with no string detour. Ingest uses the text format
only when a string column goes into a type that reads text through its input
function (see Text into any column type).
SQL type name in the field metadata
Every field the driver returns (query results, ExecuteSchema and
GetTableSchema) carries the column's SQL type in the field metadata key
ARPEPGSQL:type, spelled the way PostgreSQL's format_type spells it (what
psql \d shows): for example integer, character varying(1000),
numeric(10,2), timestamp(3) with time zone or integer[]. Enum and
extension types (such as PostGIS) are named by the server; a domain reports its
base type. On geospatial columns the key sits alongside the geoarrow.wkb
extension metadata.
Read path: PostgreSQL → Arrow
Numeric
| PostgreSQL type | Arrow type | Notes |
|---|---|---|
bool | bool | |
int2 | int16 | |
int4 | int32 | |
int8 | int64 | |
float4 | float32 | |
float8 | float64 | |
oid | uint32 | unsigned, so OIDs ≥ 2³¹ stay positive |
numeric(p,s) | decimal128(p,s) (p ≤ 38) · decimal256 (39–76) · utf8 (> 76 / unconstrained, or numeric_format=string) | no text round-trip; NaN handling: see NUMERIC special values |
money | decimal128(19, s) | s is the server's current lc_monetary scale; see Money |
An unconstrained numeric (no declared precision) has no fixed Arrow decimal
width, so it renders as utf8 (canonical PostgreSQL text).
NUMERIC special values
PostgreSQL NUMERIC can hold NaN, and (unconstrained only, PostgreSQL 14+)
Infinity / -Infinity. Arrow decimals cannot represent them, so by default a
NaN read into a decimal128/decimal256 column fails the read with an
error naming the column, rather than silently changing the value:
column "price": NUMERIC NaN/Infinity cannot be represented as decimal128(15,2);
set adbc.arpepgsql.numeric_format=string to read NUMERIC as text (lossless), or
adbc.arpepgsql.numeric_special=null to read NaN as NULL
Two options control this:
| Option | Effect |
|---|---|
adbc.arpepgsql.numeric_format=string | Every NUMERIC column is returned as utf8 in PostgreSQL's text form ("12345.67", "NaN", "Infinity"). Lossless. |
adbc.arpepgsql.numeric_special=null | Keep typed decimals and read NaN as NULL (indistinguishable from a real SQL NULL). |
Unconstrained numeric is always utf8, so its special values come back as text
and never trigger the error.
Money
money reads as decimal128(19, s), the same on every read path and for
RETURNING and data-changing WITH statements; money[] reads as a list of
it. Precision 19 holds every money value, which is a signed 64-bit integer.
The driver asks the server for the scale of the statement, so a
SET lc_monetary between statements is followed, and values never depend on
locale separators. A result without a money
column costs no extra query; numeric_format=string does not apply to
money.
Several statements in one query string cannot be described, so no scale exists
for their reply. A money column there fails, naming the column; cast it to
numeric or text in the query.
For writing money, see Write path.
Character & binary
| PostgreSQL type | Arrow type | Notes |
|---|---|---|
text / varchar / bpchar (char(n)) / name | utf8 | |
uuid | utf8 | 36-char canonical form; lowercase by default, casing via uuid_casing |
json / jsonb | utf8 | canonical PostgreSQL text; optional arrow.json extension, see JSON extension |
jsonpath | utf8 | |
inet / cidr / macaddr | utf8 | canonical PostgreSQL text |
macaddr8 | utf8 | canonical PostgreSQL text (08:00:2b:01:02:03:04:05) |
pg_lsn | utf8 | the server's text form: 16/B374D848. PostgreSQL 19 zero-pads the low half (0/00000ABC where earlier versions print 0/ABC), and the driver follows the connected server's form on every read path. |
"char" | utf8 | one character; empty for a zero byte, \ooo for a byte above 0x7F. |
enums, citext | utf8 | the label / the text. A type created by another connection is recognised the first time a result contains it. |
bit / varbit | utf8 | canonical PostgreSQL text |
xml | utf8 | text export |
bytea | binary | raw bytes |
point, line, lseg, box, path, polygon, circle | utf8 | PostgreSQL's text form; see Geometric types. |
| ranges, multiranges (built-in and user-defined) | utf8 | the server's text form, such as [1,10) or empty. |
composite and row values (ROW(...), a table's row type) | utf8 | the server's text form, such as (1,x). |
tsvector, tsquery, txid_snapshot, pg_snapshot | utf8 | the server's text form. |
extension types (hstore, ltree, ...) | utf8 | the server's text form. |
regclass, regtype, regproc, regprocedure, regoper, regoperator, regconfig, regdictionary, regnamespace, regrole, regcollation | utf8 | the server's text form: the object's name. |
xid, xid8, cid, tid, refcursor | utf8 | the server's text form (tid is (0,1)). |
aclitem, int2vector, oidvector, pg_node_tree and other catalog-internal types | utf8 | the server's text form. |
arrays (int4[], text[], ...) | list<T>, nested per dimension | the element's own mapping, typmod included (numeric(10,2)[] is list<decimal128(10,2)>); see Arrays. |
| arrays of an element with no decoding (ranges, composites, domains, ...) | utf8 | the server's array text, such as {"[1,2)"}. |
pseudo-types (void, unknown, cstring) and any other type the driver cannot name | binary | raw wire bytes |
Ranges, composites, tsvector and extension types are read in the server's
text form. Under copy_format=binary, an INSERT ... RETURNING or a
data-changing WITH returns these columns as binary.
Arrays
An array reads as a list on every path: list<T> for one dimension,
list<list<T>> for two, and so on up to PostgreSQL's six. NULL arrays, NULL
elements and empty arrays are kept. Elements map as a scalar column does, so numeric_format, numeric_special and uuid_casing apply to them.
| Element type | Reads as |
|---|---|
any type with its own decoding, bytea, enum, citext | list<T> |
money | list<decimal128(19, s)>, as the scalar |
ranges, multiranges, composites, tsvector, domains, regclass and other types with no decoding | utf8, the whole array's text |
Dimensions. PostgreSQL does not record a column's number of dimensions
reliably, and one int[] column can hold a 1-D and a 2-D value in different
rows. Each array column of a result stream therefore takes its depth from its
first non-NULL, non-empty value:
- Before answering
get_schemaor handing out its first batch, a stream with array columns reads ahead until every array column has had such a value, the result ends, or it holds 1,000,000 rows or 64 MiB of batches. The batches read meanwhile are kept and returned in order. A result with no array column is unaffected. - A column with no such value within that read-ahead reads as one dimension.
A later value of another depth fails the read, naming the column: cast the
column to
textin the query to read it. GetTableSchemaandExecuteSchemahave no rows to look at: they use the dimension count recorded in the catalog when there is one, otherwise one dimension, so a stream can turn out deeper than they report (for aCREATE TABLE AScolumn, for example).
Lower bounds. Arrow lists have nowhere to store a lower bound, so a value
whose lower bound is not 1 fails the read, naming the column. Cast it to
text, or set
adbc.arpepgsql.array_lower_bound=ignore
to read it as an ordinary list and drop the bound.
Geometric types
The built-in geometric types read as utf8 in PostgreSQL's text form, the same
on every read path and from GetTableSchema:
| Type | Text | Example |
|---|---|---|
point | (x,y) | (1.5,2.5) |
line | {A,B,C} | {1,2,3} |
lseg | [(x1,y1),(x2,y2)] | |
box | (x1,y1),(x2,y2) | |
path | open [(..),(..)], closed ((..),(..)) | |
polygon | ((..),(..)) | |
circle | <(x,y),r> | <(0,0),1> |
Floats print as the server prints them in shortest form (NaN, Infinity,
-Infinity, -0, the same digits and exponent form), independent of the
client's locale. A utf8 column in this text form ingests into an existing
geometric column (see Text into any column type);
for a bind, cast the parameter in SQL: $1::point.
JSON extension
json and jsonb read as plain utf8 by default. With
adbc.arpepgsql.json_extension=arrow.json
those columns (and GetTableSchema) carry the canonical arrow.json extension
in their field metadata next to the usual ARPEPGSQL:type; the values and the
Arrow type stay the same, so a pyarrow that has the canonical extension
registered reports pa.json_().
On ingest, a string field carrying arrow.json creates a jsonb column and
appends like utf8 (into jsonb, json, text, ...), whatever the option
above. A plain utf8 field still creates text.
Temporal
| PostgreSQL type | Arrow type | Notes |
|---|---|---|
date | date32 | days since epoch |
time(p) | time32[s|ms] or time64[us] | unit follows the column precision |
timetz | utf8 | text export (Arrow has no time-with-offset type) |
timestamp(p) | timestamp[s|ms|us] | unit follows the column precision |
timestamptz(p) | timestamp[s|ms|us, tz=UTC] | stored UTC instant |
interval | month_day_nano | Arrow's month/day/nanosecond interval |
PostgreSQL's microsecond storage resolution means true Arrow-nanosecond precision is not reachable.
Infinite dates and timestamps
date, timestamp and timestamptz can hold 'infinity' / '-infinity'
(common in history tables: valid_to = 'infinity'). Arrow date32 and
timestamp have no such value, so by default the read fails, with an
error naming the column and the
adbc.arpepgsql.temporal_infinity
option. Two ways to read such a column:
| Option value | Read | Write (ingest and bind) |
|---|---|---|
error (default) | fails, naming the column | a date32 outside PostgreSQL's date range is refused; the largest timestamp is written as the instant it is |
extreme | infinity reads as the largest value of the column's Arrow type, -infinity as the smallest: INT32_MAX / INT32_MIN days for date32, INT64_MAX / INT64_MIN for a timestamp of any unit | those two values are written as infinity / -infinity |
- With
extreme, a table read and ingested back holds the same rows. It applies on every read path and to bound queries, arrays included, and on ingest in bothCOPYformats, to bound parameters and across the date and timestamp conversions. - The extreme values lie outside PostgreSQL's finite
daterange. Fortimestamp, the one finite value equal to the Arrow limit (294247-01-10 04:00:54.775807) is refused on read underextremerather than returned asinfinity. - Set the option on the database or a connection; an open connection applies a change from its next statement.
- Without the option, map the value in the query instead:
NULLIF(valid_to, 'infinity'), or a sentinel date of your choice.
conn = dbapi.connect(driver="arpepgsql", db_kwargs={
"uri": "postgresql://alice:<password>@db.example.com/tpch",
"adbc.arpepgsql.temporal_infinity": "extreme",
})
Text row path
The text row path (copy_format=text,
servers without binary COPY, and the auto fallback) returns the same Arrow
types as the binary path. It reads timestamps in the column's
unit (s / ms / µs), applies timestamptz offsets whatever the session
TimeZone, and reads time, interval, BC dates and oid values above
2³¹; floats are parsed with . as the decimal point whatever the host locale.
A value that does not parse in full is an error, and a query that
returns more than one result set (SELECT 1; SELECT 2) fails with "query
returned more than one result set".
Session settings and the text row path (the binary COPY path does not depend
on them):
DateStyle. The driver pinsDateStyle=ISOat connect, whatever the server, database or role default. A laterSET DateStyleto another style makes text-path date/time reads fail with an error that names the setting;RESET DateStyleto read again.IntervalStyle. Interval text is read in every style (postgres,postgres_verbose,sql_standard,iso_8601), so aSET IntervalStyle, a server, database or role default, or a pooled connection left in another style reads the same values.client_encodingmust stayUTF8. A statement that changes it fails with "client_encoding was changed to ..." and the connection is closed; the next statement reconnects inUTF8(an open transaction is lost with it).
Geospatial (PostGIS)
| PostgreSQL type | Arrow type | Notes |
|---|---|---|
geometry / geography | binary + geoarrow.wkb extension (default) | ISO WKB; see Geospatial types |
Vectors (pgvector)
| PostgreSQL type | Arrow type | Notes |
|---|---|---|
vector / vector(n) | list<item: float32 not null> | see pgvector types |
halfvec / halfvec(n) | list<item: float16 not null> | |
sparsevec | struct<dim: int32, indices: list<int32 not null>, values: list<float32 not null>> | 0-based indices |
pgvector types
pgvector's vector and halfvec
columns read as Arrow lists of float32 and float16, on every read path.
The types are recognised only when they belong to the vector extension, so
an unrelated type of the same name is not taken for one; without pgvector
nothing changes. GetTableSchema reports the same list types, including for an
extension installed in a schema off the search_path. The dimension is in the
ARPEPGSQL:type metadata (vector(3)); the Arrow type is a variable-size
list, since a plain vector column holds values of any dimension.
sparsevec reads as a struct holding the dimension and the non-zero elements:
struct<dim: int32, indices: list<item: int32 not null>, values: list<item: float32 not null>>. Indices are 0-based, so {1:1.5,3:2}/5
reads as {"dim": 5, "indices": [0, 2], "values": [1.5, 2.0]}.
On the write path, a list, large_list or fixed_size_list of float32 or
float16:
- Ingest, create mode: becomes a
vector(float32) orhalfvec(float16) column,vector(n)/halfvec(n)for afixed_size_list[n]. Without pgvector theCREATE TABLEfails (type "vector" does not exist). - Ingest, append: is written in the existing column's format:
float32elements going into ahalfveccolumn are rounded tofloat16, andfloat16intovectorwidened. A list into a column of any other non-array type is refused withALREADY_EXISTSand SQLSTATE42804. A NULL element is refused (pgvector has none). - Bind: is sent as pgvector's text form (
[1,2.5,-3]), untyped like every parameter, so the server takes the type from the query:ORDER BY embedding <-> $1works with alist<float32>parameter.
A struct with exactly the sparsevec shape (fields dim int32, indices
list<int32>, values list<float32>, in that order) is written as a
sparsevec: create makes a sparsevec column, append goes into an existing
sparsevec column, and bind sends pgvector's text form. Each value is checked
before it is written: dim is positive and non-NULL, indices and values
are the same length with no NULLs, and indices are strictly increasing and in
[0, dim); otherwise INVALID_ARGUMENT names the column and row (or
parameter). Any other struct keeps its existing behaviour.
Geospatial types
PostGIS geometry / geography columns are read as EWKB, PostGIS's
extended WKB, with no ST_AsBinary needed in the query. The
adbc.arpepgsql.geospatial database
option controls what the driver does with it:
| Value | Output | Notes |
|---|---|---|
geoarrow.wkb (default) | Arrow binary + geoarrow.wkb extension | ISO WKB (rewritten from EWKB, see below) plus ARROW:extension:name=geoarrow.wkb and an ARROW:extension:metadata JSON object; read directly by GeoPandas / GeoParquet / DuckDB |
wkb | Arrow binary | EWKB bytes unchanged, no extension metadata |
binary | Arrow binary | EWKB bytes unchanged (opaque), no extension metadata |
When PostGIS is not installed this is a clean no-op.
ISO WKB in geoarrow.wkb mode. The GeoArrow
geoarrow.wkb type is ISO WKB, so in this mode each value is converted to the
same bytes ST_AsBinary(geom) would return:
- the SRID flag and the 4-byte SRID that follows it are removed; the column's
SRID is carried by the field's
crsmetadata instead (below); - the Z / M flags become ISO type codes:
+1000for Z,+2000for M,+3000for ZM (POINT ZMis type3001); - this applies to every member of a multi-geometry, geometry collection, curve, polyhedral surface or TIN, at any depth, and each geometry keeps its own byte order.
A value that is not well-formed EWKB fails the read with an error naming the
column; geospatial=wkb returns the raw bytes.
Extension metadata (CRS). In geoarrow.wkb mode the extension metadata
carries edges: spherical for geography (planar geometry omits it) and
crs: EPSG:<srid> taken from the column's PostGIS typmod. CRS is emitted only
for a typmod-constrained column (geometry(Point, 3857)) with an SRID other
than 0/4326, mirroring the GeoParquet convention, where a missing crs means
longitude/latitude (OGC:CRS84).
- A column without a typmod (plain
geometry/geography, or an expression) gets nocrs, and since ISO WKB has no SRID, the per-value SRIDs are not returned. This includes a column whose values mix SRIDs. To keep the SRID, cast to a constrained type in the query (SELECT geom::geometry(Geometry, 2154) ...), selectST_SRID(geom)as its own column, or read withgeospatial=wkbto get EWKB, which embeds the SRID in each value. - A
geographycolumn without a typmod defaults to SRID 4326 in PostGIS but can hold other geodetic SRIDs, so it also gets nocrs.
EWKB in wkb / binary modes. These modes return PostGIS's EWKB
unchanged: the SRID is embedded and Z / M are flagged in the high bits of the
geometry type rather than with ISO WKB's +1000 / +2000 type codes.
GEOS-based readers (shapely, GeoPandas) and PostGIS read it; a strict ISO-WKB
reader may reject 3D, M or SRID-carrying values. Use them when you need the
per-value SRID, or bytes to load back into PostGIS unchanged.
A geospatial column holds the same bytes whichever read path read it, the text row path included, in every mode.
Writing geometries (ingest)
ISO WKB and EWKB can both be written, so a table read in the default mode can be written back.
Append accepts a geoarrow.wkb or plain binary / large_binary /
binary_view column into geometry / geography. ISO WKB carries no SRID,
so a value takes the column's: geometry(Point,3857) stores it as SRID 3857,
and a plain geography column as 4326. A value that carries its own SRID is
sent unchanged, and the server refuses a mismatch. Z and M must match what
the column declares. A utf8 column holding WKT or hex EWKB appends into a
geometry column too, read by PostGIS as in an INSERT.
Create (create, create_append, replace): a field with the
geoarrow.wkb extension makes a PostGIS column instead of bytea. Metadata
edges: spherical gives geography, anything else geometry. The field's
crs gives the SRID:
Field crs | SRID |
|---|---|
absent ({}, or no extension metadata at all) | 4326, as GeoParquet reads a missing crs |
"EPSG:<n>" (the authority in any case) | n |
"OGC:CRS84" | 4326 |
a PROJJSON object, or a string holding a PROJJSON document, as GeoPandas (to_arrow) and geoarrow-pyarrow write | the code of the CRS's own top-level id (or the first of its top-level ids) when its authority is EPSG, or 4326 for OGC CRS84 |
null | no SRID: the way to ask for SRID 0 |
anything else (another authority such as "ESRI:102100", a PROJJSON document without a top-level EPSG identifier, malformed metadata) | no SRID |
- With an SRID the column gets a typmod naming the SRID and the dimension of
the values (
geometry(GeometryZ,3857)), because PostGIS refuses a Z or M value in a typmod that does not name it. The dimension comes from every value of the bound batches, or from the first batch of a stream. When those values are all NULL (or the stream is empty) or mix dimensions, the column gets no typmod and the driver writes the SRID into each value instead. A later batch of a stream holding a value of another dimension than the first batch's fails the ingest, naming the column and the row, and nothing is created; to mix dimensions, create the table beforehand with a plaingeometry/geographycolumn and usecreate_append. - A PROJJSON CRS without a top-level EPSG identifier (built from a PROJ string
that could not be matched to a code, a compound CRS, a bound CRS) gets no
SRID. Give such a field
"crs": "EPSG:<n>", or reproject the frame to an EPSG CRS first. - The read path omits
crsfor SRID 0 as well as 4326, so an SRID 0 column read and created back as it is lands as 4326; set"crs": nullon the field to keep SRID 0. - A plain
binaryfield with no extension keeps making abyteacolumn. - Without PostGIS the
CREATEfails withtype "geometry" does not exist. - Binding a geometry parameter is unaffected: send EWKB or text.
Write path: Arrow → PostgreSQL (ingest & bind)
On adbc_ingest (PostgreSQL COPY) and prepared-statement bind, Arrow arrays
are routed to PostgreSQL types.
Bulk ingest into an existing table (append, create_append, and
temporary tables too) reads the target table's column types (a
domain counting as its base type) before writing, so Arrow columns land in the
right type even when the source Arrow type is a generic utf8. Each Arrow
field goes to the column with exactly its name, as for a quoted identifier:
field foo writes column foo, never Foo. A table the driver read loads
back into the same column types, including unconstrained numeric, timetz,
tsvector, ranges, geometric types, hstore and oid (and, with
temporal_infinity=extreme, infinity
dates and timestamps).
- Integers, floats,
bool,decimal,date,time,timestamp(with and without timezone), andbinarymap directly.decimalcoversdecimal32,decimal64,decimal128anddecimal256intonumeric. Onlydecimal128can be bound. - Arrow
utf8goes into any column type: directly intojson,jsonb,inet,cidr,macaddr,bit/varbit,uuid,macaddr8,pg_lsn,"char", enum andcitextcolumns, and into every other type through the type's input function; see Text into any column type. - A
utf8,large_utf8,binaryorlarge_binarycolumn that holds only NULLs and empty values loads in ingest andexecutemanywhether or not its producer exported a data buffer for it (.NET exports none). An empty string into auuid,numeric,inetorjsonbcolumn is refused, as any empty string is there. - Arrow intervals land in
intervalcolumns,date64indate, anduint64innumeric, andcreatemaps them (all interval units). An Arrowdurationcolumn is rejected. - Dictionary-encoded columns (a pandas
Categorical,pa.array(...).dictionary_encode()) are written as their decoded values. A created table gets the value type's column type (textfor a string dictionary), and a NULL dictionary entry is written as NULL. - A null-type column (
pa.null()) writes NULL in every row: into whatever type the target column has on append, and as atextcolumn when the table is created. decimal128/decimal256go into an existingmoneycolumn, and adecimal128or a plain decimal string binds to amoneyparameter. The value is converted exactly to the server'slc_monetaryscale and never parsed under the server's locale; a value needing more fractional digits than the scale, or outside the 64-bit range, fails naming the column and row.utf8and integers stay refused for ingest (text would be read in the server'slc_monetary), any other bound type is refused (for an integer, write$1::int8::moneyin the SQL), and a decimal column still createsnumeric, nevermoney. In an ingest that runs in text format (because another column needs it), a decimal intomoneyis refused withNOT_IMPLEMENTED.- A
list/large_list/fixed_size_listoffloat32orfloat16is a pgvectorvector/halfvec; see pgvector types. - A
geoarrow.wkbfield makes ageometry/geographycolumn, and ISO WKB appends into one; see Writing geometries. - A column with no name is refused before any DDL runs (
INVALID_ARGUMENT, "column N has no name").
Type conversions on append
When the Arrow type and the existing column type differ, ingest converts each value or refuses the column. The driver rounds nothing: a value the column's type would change fails the ingest instead of being stored changed.
| Arrow type | Also written into | Per value |
|---|---|---|
| any integer | smallint, integer, bigint | refused if out of range |
| any integer | numeric | always exact |
| any integer | real, double precision | refused unless exactly representable |
decimal, float32, float64 | smallint, integer, bigint | whole numbers in range only (a fraction is refused) |
decimal | real, double precision | the nearest value, kept only while the column still shows the source's digits: up to 15 significant digits for double precision, 6 for real |
float64 | real | as for decimal above |
float32 | double precision | always exact |
float32, float64 | numeric | the shortest digits that read back as the float |
any integer, decimal | boolean | 0 and 1 only |
any integer, decimal (uint32 included, as an oid column reads) | oid | refused if out of range |
bool | smallint, integer, bigint, numeric | 0 / 1 |
any integer, float, decimal or bool | text, varchar, char | the text of PostgreSQL's own cast |
utf8 holding a decimal number | numeric | all its digits; NaN and Infinity included; refused if the text is not a number |
date32 / date64 | timestamp, timestamptz (midnight) | always exact |
timestamp (with or without timezone) | timestamp, timestamptz | the stored instant is the Arrow value, taken as UTC |
timestamp without timezone | date | refused unless exactly midnight and inside PostgreSQL's date range (for example an Oracle DATE, which reaches Arrow as timestamp[s]) |
utf8 | text, varchar, char, name, json, xml, bytea, and (transformed) jsonb, inet, cidr, macaddr, bit, varbit, uuid, macaddr8, pg_lsn | |
utf8 | any other type, through its input function | as the server reads the text in an INSERT; see Text into any column type |
binary, fixed_size_binary | bytea, uuid |
So an Oracle NUMBER(19) (Arrow decimal) loads into bigint, a
decimal(18,2) into double precision, a float64 into numeric, and an
unconstrained numeric the driver read as utf8 back into numeric.
numeric(p,s) rounds to its scale. The server applies a numeric(p,s)
column's declared scale to every value it receives, as for an INSERT and in
PostgreSQL's own COPY: 1.555 (float64) or 1.5555 (decimal128(18,4))
into numeric(18,2) is stored as 1.56, rounding half away from zero. A
value with too many integer digits fails with numeric field overflow.
Pairs with no conversion (int32 into date, int64 into timestamp, a
timestamp with a timezone into date, utf8 or an integer into money,
…) are refused before any row is written with ALREADY_EXISTS and SQLSTATE
42804, naming the column: cast the Arrow column first (for example with
pyarrow.compute.cast).
A value refused by a per-value check fails the ingest with INVALID_ARGUMENT
naming the column and row (the row counts from the start of the ingest,
0-based). The check runs while the rows are sent, so the ingest is aborted:
that ingest call stores nothing, and an explicit transaction it ran in is left
aborted (roll it back). Rows that other ingest calls already committed, for
example the other partitions of a parallel copy, each on its own connection,
stay. A date32 / date64 value outside PostgreSQL's date range
(4714-11-24 BC .. 5874897-12-31) is refused the same way rather than stored as
infinity (unless it is the extreme value that
temporal_infinity=extreme writes as
infinity). For column types the driver does not know (extension types), a
string column goes through the type's input function, and any other Arrow
type is sent as it is and the server decides.
An ingest error ends with the server's COPY context, such as
(COPY t, line 2, column v: "abc").
Text into any column type
A string column (utf8, a dictionary of strings, or a list of strings into an
array column) loads into any column type. Into a type that cannot take text in
binary form, the server reads each value through the type's input function, as
in an INSERT:
- the integer and float types,
boolean,date,time,timetz,timestamp,timestamptz,intervalandoid; - any type outside the driver's built-in set that is neither a string nor an
enum type:
tsvector,tsquery, ranges, multiranges, geometric types,hstore,ltree, composites,xid,regclass,jsonpath, PostGISgeometry(from WKT or hex EWKB), pgvectorvector(from[1,2,3]); - arrays of both.
Such an ingest runs as a text-format COPY, and its other columns are written
as text too, with the same conversions and per-value checks as in binary
format. It runs at the speed of PostgreSQL's own text COPY, about 1.6 times
the time of a binary one; an ingest with no such column stays in binary
format, and utf8 into numeric stays binary. A value the server refuses
fails the ingest with its message and COPY context, for example
invalid input syntax for type integer: "abc" (COPY t, line 2, column v: "abc").
Nothing has to be set.
Text into money stays refused, since its input function reads the text in
the server's lc_monetary.
Lists and arrays
A list, large_list or fixed_size_list is written as a PostgreSQL array:
when the driver creates the table the column is the element's type with [],
and into an existing array column each element follows the same conversion
rules as a scalar (int32 or decimal into bigint[]; a float64 element
with a fraction into integer[] fails, naming the column and row; a list of
strings into integer[] or date[] goes through the element type's input
function). Into a non-array column it is refused. A list of float32 or
float16 stays a pgvector vector / halfvec on create, and is written as
an array only when the existing column is an array (real[] and the like). A
list of decimals goes into money[].
As a bound parameter a list is sent as an array literal, and the server infers
its type from the query (= ANY($1), $1::int[]). decimal256, interval and
nested lists cannot be bound, a list of float32 / float16 is bound as
pgvector only, and a list cannot be bound to a money[] parameter (use
ingest).
Other limits
Ingest from bound arrays and from a bound stream both read the target's column types (a bound stream is consumed one batch at a time). On CedarDB, which does not list temporary tables in its catalogs, ingest into an existing temporary table sends the Arrow types unchanged, without these conversions.
An Arrow string or binary array whose offsets declare value bytes while it has
no data buffer is malformed and is refused with
malformed Arrow array: the data buffer is NULL but the offsets are not all 0,
naming the column and row on ingest, or the parameter in executemany, where
the bind fails with INVALID_ARGUMENT (ProgrammingError in Python).
Arrow inputs with no PostgreSQL equivalent, and Arrow nanosecond temporal
precision (PostgreSQL tops out at microseconds), are rejected with NOT_IMPLEMENTED.
See also
- Connection → Type rendering — the
uuid_casing,numeric_*,array_lower_bound,temporal_infinity,json_extensionandgeospatialoptions - Compatibility — validated PostgreSQL versions
- Examples — reading and ingesting typed data