ArpeOracle — Data types
How Oracle types map to Apache Arrow on the fetch (read) path, and how Arrow types map back to Oracle on the ingest/bind (write) path.
The non-obvious cases — unconstrained NUMBER has no exact Arrow type, DATE
carries a time component (so it is a timestamp, not date32), TIMESTAMP WITH TIME ZONE collapses to a UTC instant, and INTERVAL types default to
Parquet-writable Arrow types rather than interval (month_day_nano) — are called
out below.
Read path: Oracle → Arrow
Numeric
| Oracle type | Arrow type | Notes |
|---|---|---|
NUMBER(p,0), p ≤ 18 | int64 | Max 999,999,999,999,999,999 < 263; better for every consumer than a zero-scale decimal |
NUMBER(p,0), p 19–38 | decimal128(p,0) | Can exceed int64 |
NUMBER(p,s), s > 0 | decimal128(p,s) | Exact; Oracle's max precision is 38, so decimal256 is never needed |
NUMBER(p,-s), p + s ≤ 38 | decimal128(p+s,0) | A negative scale rounds to 10s: NUMBER(5,-2) holds up to 9,999,900, so decimal128(7,0). Since v0.4.1 (decimal128(p,0) before) |
NUMBER(p,-s), p + s > 38 | as unconstrained NUMBER | No decimal128 holds it; governed by number_mapping. Since v0.4.1 |
NUMBER (unconstrained) | utf8 (default) / float64 / decimal128(P,S) | Governed by number_mapping |
BINARY_INTEGER | as NUMBER above | Same policy path |
BINARY_FLOAT | float32 | |
BINARY_DOUBLE | float64 |
Character & binary
| Oracle type | Arrow type | Notes |
|---|---|---|
VARCHAR2 / CHAR / LONG | utf8 | AL32UTF8 passes through unchanged |
NVARCHAR2 / NCHAR | utf8 | National charset (AL16UTF16) transcoded UTF-16 → UTF-8 |
RAW / LONG RAW | binary | |
ROWID / UROWID | utf8 | Oracle's printable rowid string (the 18-character form ROWIDTOCHAR returns); a logical (index-organized table) UROWID renders as * followed by base-64 |
CLOB | utf8 | up to 4000 characters (UTF-16 code units) arrive in the row; a longer value costs one LOB read round trip after the fetch (since v0.4.1; every value cost two before) |
NCLOB | utf8 | national CLOB, UTF-16 → UTF-8; read like CLOB |
BLOB | binary | up to 4000 bytes in the row; a longer value costs one LOB read round trip |
XMLTYPE | utf8 | The document as text. Binary-XML storage (the default) arrives in the row; CLOB storage (STORE AS CLOB) is read through its LOB locator after the fetch. Since v0.3.12 |
utf8 and binary arrays have 32-bit offsets, so one column holds at most
2 GiB per batch. A batch whose CLOB, NCLOB, BLOB or LOB-stored XMLTYPE
values would pass that ends early, before the row that does not fit, and that
row opens the next batch: batches can then be shorter than batch_size, and the
schema stays utf8/binary. A single LOB value larger than the limit fails the
query with an error naming the column. LONG and LONG RAW values arrive
inside the fetch reply, so their batch cannot be cut: a batch of more than
2 GiB of them fails with an error asking for a smaller
adbc.arpeoracle.batch_size. Since v0.4.1; before that such a query failed.
Temporal
| Oracle type | Arrow type | Notes |
|---|---|---|
DATE | timestamp[s] | Not date32 — Oracle DATE always carries a time component |
TIMESTAMP(n) | timestamp[s|ms|us|ns] | unit follows the column's fractional-seconds precision |
TIMESTAMP(n) WITH TIME ZONE | timestamp[…, tz=UTC] | UTC instant; the original offset or named region is not kept |
TIMESTAMP(n) WITH LOCAL TIME ZONE | timestamp[…, tz=UTC] | wire value is UTC (DBTIMEZONE assumed UTC) |
INTERVAL YEAR TO MONTH | int64 (default) / interval (month_day_nano) | Default is the total number of months; governed by interval_mapping |
INTERVAL DAY TO SECOND | utf8 (default) / interval (month_day_nano) | Default is an ISO-8601 duration string; governed by interval_mapping |
Fractional-seconds precision → unit (for TIMESTAMP and its TZ variants):
| Column precision | Arrow unit |
|---|---|
| 0 | seconds |
| 1–3 | milliseconds |
| 4–6 | microseconds |
| 7–9 | nanoseconds |
Oracle allows up to 9 fractional digits, so the precision is rounded up to the next representable Arrow unit and no precision is lost.
timestamp[ns] is an int64 count of nanoseconds, which only spans
1677-09-21 to 2262-04-11; the coarser units cover every year Oracle stores
(-4712 to 9999). A TIMESTAMP(7..9) value outside that span (a 9999-12-31
"end of time" sentinel, say) fails the query with INVALID_DATA / SQLSTATE
22008 (TIMESTAMP value ... is out of range for timestamp[ns]); it is never
wrapped or turned into NULL. CAST the column to TIMESTAMP(6)
(timestamp[us]) in the query to read such values.
Calendar
Since ArpeOracle v0.4.1. Earlier versions read dates before 1582-10-15 as Gregorian labels, up to 10 days off and more further back.
Arrow timestamps count time on the proleptic Gregorian calendar; Oracle's
DATE and TIMESTAMP use the Julian calendar before 1582-10-15. The driver
converts between the two on read and on write, so a value is the same day on
both sides, not the same label: the Arrow value of an Oracle date is the day
count Oracle itself gives, d - DATE '1970-01-01'. From 1582-10-15 on the two
calendars agree and nothing changes. Before it, Oracle's 1582-10-04 is the
day before 1582-10-15, and Julian leap days such as 1500-02-29 exist (it
reads as the Gregorian 1500-03-10). A BC year -n reads as the astronomical
year -n (n + 1 BC). A fetched date that is not a day of Oracle's calendar
(a 31 February, a day of the 1582 gap, year 0) fails the fetch with
INVALID_DATA / SQLSTATE 22007.
Oracle 23ai native types
Since ArpeOracle v0.2.10, decoded natively on Oracle 23ai / 26ai.
| Oracle type | Arrow type | Notes |
|---|---|---|
BOOLEAN | bool | 23ai native boolean |
JSON | utf8 | Native JSON as JSON text, for a JSON column and for a JSON-typed expression alike (JSON('...'), JSON_OBJECT(... RETURNING JSON), dot notation such as t.doc.a), written as JSON_SERIALIZE writes it. On Oracle 21c too: a JSON column there is utf8 since v0.3.12 and a JSON-typed expression since v0.4.1 (both read as binary before) |
VECTOR | list<float32 | float64 | int8> | 23ai vectors; the element type follows the column's VECTOR format |
Spatial
Since ArpeOracle v0.3.1, on Oracle with the Spatial option.
| Oracle type | Arrow type | Notes |
|---|---|---|
MDSYS.SDO_GEOMETRY | binary + geoarrow.wkb extension | Decoded to little-endian ISO WKB, tagged ARROW:extension:name = geoarrow.wkb so consumers such as GeoPandas or DuckDB spatial treat it as geometry. The stored SDO_SRID (taken from the first non-null geometry in the result) is surfaced as the geoarrow CRS metadata ({"crs_type":"srid","crs":N}), or forced with the arpeoracle.sdo.srid statement option. On read, POINT, LINESTRING, and single-exterior-ring POLYGON are decoded (any size). The write path below is broader. |
Since v0.4.1, 3D geometries read as ISO WKB Z types, measured (LRS) ones as M
types and 4D ones as ZM types; a 2D optimized rectangle reads as its 5-point
polygon and a point stored in SDO_ORDINATES as a point, as
SDO_UTIL.TO_WKBGEOMETRY returns them; a NULL SDO_POINT with no ordinates
reads as POINT EMPTY. Geometries built by SDO_UTIL.FROM_WKTGEOMETRY /
FROM_WKBGEOMETRY read too. Still out of scope on read, and failing the fetch
with an error naming the geometry type and the reason: multi-part geometries,
polygons with interior rings, circular arcs, circles, compound elements,
oriented points, 3D optimized rectangles and geometry collections.
Not yet mapped
BFILE— a pointer to a server-filesystem file through aDIRECTORYobject; a different permission model, not a different encoding, so it is surfaced as unsupported rather than half-decoded.JSONbefore 21c,BOOLEANbefore 23ai — not native column types on those versions (JSONis stored in a LOB/VARCHAR2with anIS JSONcheck), so such a column decodes as its underlying text/LOB type. The nativeJSONtype (21c and later) andBOOLEAN(23ai) are decoded directly — see Oracle 23ai native types above.- Other types — object types other than
SDO_GEOMETRYandXMLTYPE, collections, and any type not listed above — are refused rather than guessed at: the query fails withcolumn <name> (Oracle type <n>) is not supported by this driver yet.
Oracle type name (ARPEORACLE:type)
Since ArpeOracle v0.3.12.
Every field of a result schema (ExecuteQuery, ExecuteSchema and
GetTableSchema alike) carries its Oracle column type in the field metadata
under ARPEORACLE:type, spelled as Oracle spells it in DDL and the data
dictionary: VARCHAR2(100), NUMBER(12,2), FLOAT(126), DATE,
TIMESTAMP(6) WITH TIME ZONE, INTERVAL DAY(4) TO SECOND(6), CLOB, UROWID,
JSON, SYS.XMLTYPE, and on 23ai BOOLEAN and VECTOR(3, FLOAT32); an object
type is SCHEMA.NAME (MDSYS.SDO_GEOMETRY, next to its geoarrow.wkb
extension keys). It tells apart columns that share an Arrow type (VARCHAR2
and CHAR, DATE and TIMESTAMP(0)). String lengths are in characters,
without a BYTE/CHAR suffix, and INTEGER reads NUMBER(38), as Oracle's
own clients report it.
Number Mapping
Oracle's unconstrained NUMBER (no declared precision or scale) is Oracle's default numeric type and has no exact Arrow equivalent.
A fixed decimal128(p,s) cannot be chosen safely (it would truncate high-scale
values and overflow large ones), and an Arrow schema is fixed before the first
batch, so the scale cannot be inferred by looking ahead in the stream. The
adbc.arpeoracle.number_mapping database
option chooses:
| Value | Output | Notes |
|---|---|---|
auto (default) | utf8 | Lossless. The deliberate default — a lossy default would silently lose precision on Oracle's most common numeric column |
double | float64 | Fast, lossy — 15–17 significant digits against Oracle's 38 |
decimal:P,S | decimal128(P,S) | For callers who know their data; 1 ≤ P ≤ 38, 0 ≤ S ≤ P |
Constrained columns are unaffected by this option — only unconstrained NUMBER
(and a NUMBER(p,-s) wider than 38 digits) is routed through it. The lossless
default matters in practice: an unconstrained NUMBER can hold values with more
significant digits (21 and beyond) than float64 can represent.
A value that does not fit decimal128(P,S) fails the query; it is never
rounded, truncated or turned into NULL (since v0.4.1; before that such a
value was written unchecked and came back wrong). That is a value of
10P−S or more in magnitude, or one with more than S fractional
digits: under decimal:10,2, 1E20, 100000000 and 1.23456 all fail. The
error is INVALID_DATA with SQLSTATE 22003 and names the column, the row, the
value and the target type, e.g. failed to decode column 0 (N) of row 0: NUMBER value 1.23456 has more fractional digits than decimal128(10,2) holds. The
session and an open transaction survive: the next statement runs on the same
session.
Interval Mapping
Since ArpeOracle v0.3.7. The default changed in v0.3.7 — see the note below.
Arrow's interval(month_day_nano) type has no Parquet
representation, so any Parquet-writing consumer (FastBCP, pandas→parquet, …)
drops or errors on interval columns rendered that way. The default therefore maps
both interval types to Parquet-writable, lossless Arrow types — matching the Arrow
schema FastBCP's regular Oracle driver (oraodp) produces, so the Parquet schema
is identical across connectors. The
adbc.arpeoracle.interval_mapping
database option chooses:
| Value | INTERVAL YEAR TO MONTH | INTERVAL DAY TO SECOND | Notes |
|---|---|---|---|
parquet (default) | int64 (total months) | utf8 (ISO-8601 duration) | Both lossless and Parquet-writable |
native | interval (month_day_nano) | interval (month_day_nano) | Arrow-native, but not Parquet-writable |
The ISO-8601 duration format is [-]P{D}DT{H}H{Mi}M{S}[.frac]S — e.g. a
+4 05:06:07.891011 interval renders as P4DT5H6M7.891011S, and
-1 02:03:04.5 as -P1DT2H3M4.5S.
Before v0.3.7 both interval types defaulted to interval (month_day_nano). A
consumer relying on that output must now set interval_mapping=native to restore
it.
Write path: Arrow → Oracle (ingest & bind)
On prepared-statement bind, Arrow arrays drive positional binds — one Arrow
row is one execution. adbc_ingest (in create / append / replace /
create_append modes, with optional target_db_schema and a
GLOBAL TEMPORARY target, adbc.ingest.temporary) loads by direct path
when the target allows it (since v0.4.0) and otherwise issues an array-bound
INSERT, with a SQL-injection-safe identifier and literal escaper. See
Connection → Ingest method for
the choice and the ingest options.
Table, schema and column names are quoted exactly as given, so they are
case-sensitive: ingesting into my_table creates "my_table", which an
unquoted SELECT … FROM my_table (folded to MY_TABLE) does not find. Use
upper-case names to get ordinary unquoted Oracle identifiers.
When the ingest creates the table (create, replace, or create_append on a
missing table), each Arrow column becomes:
| Arrow type | Oracle column |
|---|---|
bool | NUMBER(1) |
int8 / uint8 | NUMBER(3) |
int16 / uint16 | NUMBER(5) |
int32 / uint32 | NUMBER(10) |
int64 | NUMBER(19) |
uint64 | NUMBER(20) (since v0.4.1; NUMBER(19) before, which could not hold values of 1019 or more) |
float32 | BINARY_FLOAT |
float64 | BINARY_DOUBLE |
decimal128(p,s) | NUMBER(p,s) |
utf8 / large_utf8 / string_view | VARCHAR2(4000) (string_view since v0.4.1) |
binary / large_binary / binary_view | RAW(2000) (binary_view since v0.4.1) |
fixed_size_binary(n), n ≤ 2000 | RAW(n) |
binary tagged geoarrow.wkb | MDSYS.SDO_GEOMETRY |
date32 / date64 | DATE |
timestamp[s|ms|us|ns] | TIMESTAMP(0|3|6|9) |
timestamp[…, tz=…] | TIMESTAMP(0|3|6|9) WITH TIME ZONE |
null | VARCHAR2(1) |
Any other Arrow type (float16, decimal256, lists, structs, intervals, …) is
rejected with cannot create a column for Arrow type …. Ingest creates and
loads tables of any width Oracle allows (up to 1,000 columns; since v0.4.1).
The create, the bind and the direct path accept and refuse the same Arrow
input: a decimal128 needs a precision of 1 to 38 and a scale Oracle NUMBER
can have (-84 to 127; a decimal128 outside that is refused since v0.4.1,
where the INSERT bind used to store it scaled wrongly), and a malformed
format string is refused rather than partly read. string_view and
binary_view columns (as newer Polars and pyarrow produce) are written exactly
as utf8 and binary are (since v0.4.1).
A dictionary-encoded column is written as its values (since v0.3.12; its
integer indices were written before): it binds, and an ingest creates its
column, exactly as the dictionary's value type would (a
dictionary<int32, utf8> becomes VARCHAR2). A NULL index or a NULL dictionary
entry is a NULL value, and an index outside the dictionary fails the bind.
A date or timestamp outside Oracle's range (years -4712 to 9999) fails the bind
or the load with INVALID_DATA / SQLSTATE 22008, naming the row (counted
from 1) and the column, e.g. row 2, column "WHEN": the date is outside Oracle's range; it is never wrapped into the range (since v0.4.1). Dates
before 1582-10-15 are converted to Oracle's Julian calendar (see
Calendar).
Direct path load
Since ArpeOracle v0.4.0.
A direct path load stores each value exactly as sent, so the driver encodes it
in the target column's type and applies what an INSERT would, with the same
result:
| Target column | Arrow types loaded by direct path | Applied by the driver |
|---|---|---|
NUMBER(p,s), NUMBER, FLOAT(b) | integers, unsigned integers, bool, decimal128, float, double | Rounded half away from zero to scale s (to FLOAT(b)'s significant digits); more than p - s integer digits is refused (as ORA-01438). A double keeps 17 significant digits and a float 9, as Oracle's own conversion does. NaN and infinity are refused. |
BINARY_FLOAT, BINARY_DOUBLE | integers, bool, float, double | — |
DATE | date32, date64, timestamps | Fractional seconds dropped. |
TIMESTAMP(f) | date32, date64, timestamps | Fraction rounded to f digits. |
TIMESTAMP(f) WITH TIME ZONE | timestamps with a time zone | Stored as the UTC instant, offset +00:00. |
VARCHAR2, CHAR | utf8, large_utf8, string_view (AL32UTF8/UTF8 databases only) | Length checked in bytes and, under character semantics, characters; CHAR blank-padded; '' is NULL. |
RAW | binary, large_binary, binary_view, fixed_size_binary | Length checked. |
NOT NULL is checked on every column, and a dictionary-encoded column is
loaded as its values. Other target types (LOBs, LONG, NCHAR/NVARCHAR2,
intervals, TIMESTAMP WITH LOCAL TIME ZONE, SDO_GEOMETRY and other objects,
23ai JSON/VECTOR/BOOLEAN) and other Arrow → Oracle pairs (a string into a
NUMBER, binary into VARCHAR2) are not loaded by direct path: with the
default auto method the ingest uses INSERT instead, where Oracle converts
as usual.
Spatial ingest
A geoarrow.wkb Arrow column is ingested as a real MDSYS.SDO_GEOMETRY column —
the inverse of the spatial read path (since v0.3.1). The create-table DDL emits
the SDO_GEOMETRY type, each row's WKB is converted to Oracle's packed object
image and bound as an OBJECT, a geoarrow CRS on the field maps to SDO_SRID,
and — when the ingest itself creates the table — USER_SDO_GEOM_METADATA and a
spatial index are registered. The write path is broader than read: in
addition to points, lines, and single-ring polygons, it supports POLYGON with
interior rings and the MULTIPOINT / MULTILINESTRING / MULTIPOLYGON kinds.
3D geometries, geometry collections, and malformed WKB are rejected, with an
error naming the row and the reason.
Since v0.4.1:
- An empty geometry (
POINT EMPTY,LINESTRING EMPTY, aPOLYGONorMULTI*with no part) is written as a NULLSDO_GEOMETRY, and an empty part of aMULTI*is dropped. - A polygon ring wound the wrong way for Oracle (a clockwise exterior ring, a counter-clockwise hole, as shapefile-sourced data often has) is reversed, so the stored geometry is valid.
- A PROJJSON CRS (as GeoPandas writes it) gives the SRID of its own top-level
id; the ids of nested parts (datum ensemble members, base CRS) are ignored. - The spatial index is named
<table>_<column>_sidx, shortened with a hash when that is longer than the server's identifier limit. - Oracle Spatial can only index a table whose name reads the same unquoted (an
uppercase ASCII letter, then uppercase ASCII letters, digits,
_,$or#). A spatialcreateorreplaceinto any other name is refused withINVALID_ARGUMENTbefore anything is sent: use such a name, or setarpeoracle.sdo.spatial_indextofalseto load without a spatial index.
See also
- Connection — the
number_mappingandinterval_mappingoptions - Compatibility — validated Oracle versions
- Examples — reading and ingesting typed data