Skip to main content

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 typeArrow typeNotes
boolbool
int2int16
int4int32
int8int64
float4float32
float8float64
oiduint32unsigned, 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
moneydecimal128(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:

OptionEffect
adbc.arpepgsql.numeric_format=stringEvery NUMERIC column is returned as utf8 in PostgreSQL's text form ("12345.67", "NaN", "Infinity"). Lossless.
adbc.arpepgsql.numeric_special=nullKeep 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 typeArrow typeNotes
text / varchar / bpchar (char(n)) / nameutf8
uuidutf836-char canonical form; lowercase by default, casing via uuid_casing
json / jsonbutf8canonical PostgreSQL text; optional arrow.json extension, see JSON extension
jsonpathutf8
inet / cidr / macaddrutf8canonical PostgreSQL text
macaddr8utf8canonical PostgreSQL text (08:00:2b:01:02:03:04:05)
pg_lsnutf8the 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"utf8one character; empty for a zero byte, \ooo for a byte above 0x7F.
enums, citextutf8the label / the text. A type created by another connection is recognised the first time a result contains it.
bit / varbitutf8canonical PostgreSQL text
xmlutf8text export
byteabinaryraw bytes
point, line, lseg, box, path, polygon, circleutf8PostgreSQL's text form; see Geometric types.
ranges, multiranges (built-in and user-defined)utf8the server's text form, such as [1,10) or empty.
composite and row values (ROW(...), a table's row type)utf8the server's text form, such as (1,x).
tsvector, tsquery, txid_snapshot, pg_snapshotutf8the server's text form.
extension types (hstore, ltree, ...)utf8the server's text form.
regclass, regtype, regproc, regprocedure, regoper, regoperator, regconfig, regdictionary, regnamespace, regrole, regcollationutf8the server's text form: the object's name.
xid, xid8, cid, tid, refcursorutf8the server's text form (tid is (0,1)).
aclitem, int2vector, oidvector, pg_node_tree and other catalog-internal typesutf8the server's text form.
arrays (int4[], text[], ...)list<T>, nested per dimensionthe 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, ...)utf8the server's array text, such as {"[1,2)"}.
pseudo-types (void, unknown, cstring) and any other type the driver cannot namebinaryraw 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 typeReads as
any type with its own decoding, bytea, enum, citextlist<T>
moneylist<decimal128(19, s)>, as the scalar
ranges, multiranges, composites, tsvector, domains, regclass and other types with no decodingutf8, 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_schema or 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 text in the query to read it.
  • GetTableSchema and ExecuteSchema have 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 a CREATE TABLE AS column, 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:

TypeTextExample
point(x,y)(1.5,2.5)
line{A,B,C}{1,2,3}
lseg[(x1,y1),(x2,y2)]
box(x1,y1),(x2,y2)
pathopen [(..),(..)], 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 typeArrow typeNotes
datedate32days since epoch
time(p)time32[s|ms] or time64[us]unit follows the column precision
timetzutf8text 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
intervalmonth_day_nanoArrow'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 valueReadWrite (ingest and bind)
error (default)fails, naming the columna date32 outside PostgreSQL's date range is refused; the largest timestamp is written as the instant it is
extremeinfinity 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 unitthose 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 both COPY formats, to bound parameters and across the date and timestamp conversions.
  • The extreme values lie outside PostgreSQL's finite date range. For timestamp, the one finite value equal to the Arrow limit (294247-01-10 04:00:54.775807) is refused on read under extreme rather than returned as infinity.
  • 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.
Python
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 pins DateStyle=ISO at connect, whatever the server, database or role default. A later SET DateStyle to another style makes text-path date/time reads fail with an error that names the setting; RESET DateStyle to read again.
  • IntervalStyle. Interval text is read in every style (postgres, postgres_verbose, sql_standard, iso_8601), so a SET IntervalStyle, a server, database or role default, or a pooled connection left in another style reads the same values.
  • client_encoding must stay UTF8. A statement that changes it fails with "client_encoding was changed to ..." and the connection is closed; the next statement reconnects in UTF8 (an open transaction is lost with it).

Geospatial (PostGIS)​

PostgreSQL typeArrow typeNotes
geometry / geographybinary + geoarrow.wkb extension (default)ISO WKB; see Geospatial types

Vectors (pgvector)​

PostgreSQL typeArrow typeNotes
vector / vector(n)list<item: float32 not null>see pgvector types
halfvec / halfvec(n)list<item: float16 not null>
sparsevecstruct<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) or halfvec (float16) column, vector(n) / halfvec(n) for a fixed_size_list[n]. Without pgvector the CREATE TABLE fails (type "vector" does not exist).
  • Ingest, append: is written in the existing column's format: float32 elements going into a halfvec column are rounded to float16, and float16 into vector widened. A list into a column of any other non-array type is refused with ALREADY_EXISTS and SQLSTATE 42804. 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 <-> $1 works with a list<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:

ValueOutputNotes
geoarrow.wkb (default)Arrow binary + geoarrow.wkb extensionISO 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
wkbArrow binaryEWKB bytes unchanged, no extension metadata
binaryArrow binaryEWKB 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 crs metadata instead (below);
  • the Z / M flags become ISO type codes: +1000 for Z, +2000 for M, +3000 for ZM (POINT ZM is type 3001);
  • 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 no crs, 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) ...), select ST_SRID(geom) as its own column, or read with geospatial=wkb to get EWKB, which embeds the SRID in each value.
  • A geography column without a typmod defaults to SRID 4326 in PostGIS but can hold other geodetic SRIDs, so it also gets no crs.

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 crsSRID
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 writethe 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
nullno 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 plain geometry / geography column and use create_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 crs for SRID 0 as well as 4326, so an SRID 0 column read and created back as it is lands as 4326; set "crs": null on the field to keep SRID 0.
  • A plain binary field with no extension keeps making a bytea column.
  • Without PostGIS the CREATE fails with type "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), and binary map directly. decimal covers decimal32, decimal64, decimal128 and decimal256 into numeric. Only decimal128 can be bound.
  • Arrow utf8 goes into any column type: directly into json, jsonb, inet, cidr, macaddr, bit/varbit, uuid, macaddr8, pg_lsn, "char", enum and citext columns, and into every other type through the type's input function; see Text into any column type.
  • A utf8, large_utf8, binary or large_binary column that holds only NULLs and empty values loads in ingest and executemany whether or not its producer exported a data buffer for it (.NET exports none). An empty string into a uuid, numeric, inet or jsonb column is refused, as any empty string is there.
  • Arrow intervals land in interval columns, date64 in date, and uint64 in numeric, and create maps them (all interval units). An Arrow duration column 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 (text for 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 a text column when the table is created.
  • decimal128 / decimal256 go into an existing money column, and a decimal128 or a plain decimal string binds to a money parameter. The value is converted exactly to the server's lc_monetary scale 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. utf8 and integers stay refused for ingest (text would be read in the server's lc_monetary), any other bound type is refused (for an integer, write $1::int8::money in the SQL), and a decimal column still creates numeric, never money. In an ingest that runs in text format (because another column needs it), a decimal into money is refused with NOT_IMPLEMENTED.
  • A list / large_list / fixed_size_list of float32 or float16 is a pgvector vector / halfvec; see pgvector types.
  • A geoarrow.wkb field makes a geometry / geography column, 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 typeAlso written intoPer value
any integersmallint, integer, bigintrefused if out of range
any integernumericalways exact
any integerreal, double precisionrefused unless exactly representable
decimal, float32, float64smallint, integer, bigintwhole numbers in range only (a fraction is refused)
decimalreal, double precisionthe nearest value, kept only while the column still shows the source's digits: up to 15 significant digits for double precision, 6 for real
float64realas for decimal above
float32double precisionalways exact
float32, float64numericthe shortest digits that read back as the float
any integer, decimalboolean0 and 1 only
any integer, decimal (uint32 included, as an oid column reads)oidrefused if out of range
boolsmallint, integer, bigint, numeric0 / 1
any integer, float, decimal or booltext, varchar, charthe text of PostgreSQL's own cast
utf8 holding a decimal numbernumericall its digits; NaN and Infinity included; refused if the text is not a number
date32 / date64timestamp, timestamptz (midnight)always exact
timestamp (with or without timezone)timestamp, timestamptzthe stored instant is the Arrow value, taken as UTC
timestamp without timezonedaterefused unless exactly midnight and inside PostgreSQL's date range (for example an Oracle DATE, which reaches Arrow as timestamp[s])
utf8text, varchar, char, name, json, xml, bytea, and (transformed) jsonb, inet, cidr, macaddr, bit, varbit, uuid, macaddr8, pg_lsn
utf8any other type, through its input functionas the server reads the text in an INSERT; see Text into any column type
binary, fixed_size_binarybytea, 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, interval and oid;
  • 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, PostGIS geometry (from WKT or hex EWKB), pgvector vector (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​