Skip to content

Commit 8229dd2

Browse files
Remove use of the DataFrame interchange protocol in favor of the Arrow
PyCapsule interface; add top-level objects "DataFrame" and "ArrowArray" for consistency with the rest of the package.
1 parent fc8618a commit 8229dd2

36 files changed

+1143
-2249
lines changed

doc/src/api_manual/async_connection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ AsyncConnection Methods
147147

148148
.. note::
149149

150-
The data frame support in python-oracledb 3.2 is a pre-release and may
150+
The data frame support in python-oracledb 3.3 is a pre-release and may
151151
change in a future version.
152152

153153
.. versionadded:: 3.0.0
@@ -175,7 +175,7 @@ AsyncConnection Methods
175175

176176
.. note::
177177

178-
The data frame support in python-oracledb 3.2 is a pre-release and may
178+
The data frame support in python-oracledb 3.3 is a pre-release and may
179179
change in a future version.
180180

181181
.. versionadded:: 3.0.0

doc/src/api_manual/connection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Connection Methods
140140

141141
.. note::
142142

143-
The data frame support in python-oracledb 3.2 is a pre-release and may
143+
The data frame support in python-oracledb 3.3 is a pre-release and may
144144
change in a future version.
145145

146146
.. dbapimethodextension::
@@ -172,7 +172,7 @@ Connection Methods
172172

173173
.. note::
174174

175-
The data frame support in python-oracledb 3.2 is a pre-release and may
175+
The data frame support in python-oracledb 3.3 is a pre-release and may
176176
change in a future version.
177177

178178
.. dbapimethodextension::

doc/src/api_manual/dataframe.rst

Lines changed: 3 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from Oracle Database types to Arrow data types.
1313

1414
.. note::
1515

16-
The data frame support in python-oracledb 3.2 is a pre-release and may
16+
The data frame support in python-oracledb 3.3 is a pre-release and may
1717
change in a future version.
1818

1919
.. _oracledataframeobj:
@@ -37,45 +37,25 @@ interface, giving access to the underlying Arrow array.
3737
OracleDataFrame Methods
3838
-----------------------
3939

40-
The object implements the Python DataFrame Interchange Protocol `DataFrame API
41-
Interface <https://data-apis.org/dataframe-protocol/latest/API.html>`__
42-
4340
.. method:: OracleDataFrame.column_arrays()
4441

4542
Returns a list of :ref:`OracleArrowArray <oraclearrowarrayobj>` objects,
4643
each containing a select list column.
4744

48-
This is an extension to the DataFrame Interchange Protocol.
49-
5045
.. method:: OracleDataFrame.column_names()
5146

5247
Returns a list of the column names in the data frame.
5348

54-
.. method:: OracleDataFrame.get_chunks(n_chunks)
55-
56-
Returns itself, since python-oracledb only uses one chunk.
57-
5849
.. method:: OracleDataFrame.get_column(i)
5950

60-
Returns an :ref:`OracleColumn <oraclearrowarrayobj>` object for the column
51+
Returns an :ref:`OracleArrowArray <oraclearrowarrayobj>` object for the column
6152
at the given index ``i``.
6253

6354
.. method:: OracleDataFrame.get_column_by_name(name)
6455

65-
Returns an :ref:`OracleColumn <oraclearrowarrayobj>` object for the column
56+
Returns an :ref:`OracleArrowArray <oraclearrowarrayobj>` object for the column
6657
with the given name ``name``.
6758

68-
.. method:: OracleDataFrame.get_columns()
69-
70-
Returns a list of :ref:`OracleColumn <oraclearrowarrayobj>` objects, one
71-
object for each column in the data frame.
72-
73-
.. method:: OracleDataFrame.num_chunks()
74-
75-
Return the number of chunks the data frame consists of.
76-
77-
This always returns 1.
78-
7959
.. method:: OracleDataFrame.num_columns()
8060

8161
Returns the number of columns in the data frame.
@@ -109,120 +89,3 @@ These are used for conversion to `PyArrow Tables
10989
:ref:`dataframeformat`.
11090

11191
.. versionadded:: 3.0.0
112-
113-
.. _oraclecolumnobj:
114-
115-
OracleColumn Objects
116-
====================
117-
118-
OracleColumn objects are returned by :meth:`OracleDataFrame.get_column()`,
119-
:meth:`OracleDataFrame.get_column_by_name()`, and
120-
:meth:`OracleDataFrame.get_columns()`.
121-
122-
.. versionadded:: 3.0.0
123-
124-
.. _oraclecolumnmeth:
125-
126-
OracleColumn Methods
127-
--------------------
128-
129-
.. method:: OracleColumn.get_buffers()
130-
131-
Returns a dictionary containing the underlying buffers.
132-
133-
The returned dictionary contains the ``data``, ``validity``, and ``offset``
134-
keys.
135-
136-
The ``data`` attribute is a two-element tuple whose first element is a
137-
buffer containing the data and whose second element is the data buffer's
138-
associated dtype.
139-
140-
The ``validity`` attribute is a a two-element tuple whose first element
141-
is a buffer containing mask values indicating missing data and whose
142-
second element is the mask value buffer's associated dtype. The value of
143-
this attribute is *None* if the null representation is not a bit or byte
144-
mask.
145-
146-
The ``offset`` attribute is a two-element tuple whose first element is a
147-
buffer containing the offset values for variable-size binary data (for
148-
example, variable-length strings) and whose second element is the offsets
149-
buffer's associated dtype. The value of this attribute is *None* if the
150-
data buffer does not have an associated offsets buffer.
151-
152-
.. method:: OracleColumn.get_chunks(n_chunks)
153-
154-
Returns itself, since python-oracledb only uses one chunk.
155-
156-
.. method:: OracleColumn.num_chunks()
157-
158-
Returns the number of chunks the column consists of.
159-
160-
This always returns 1.
161-
162-
.. method:: OracleColumn.size()
163-
164-
Returns the number of rows in the column.
165-
166-
.. _oraclecolumnattr:
167-
168-
OracleColumn Attributes
169-
-----------------------
170-
171-
.. attribute:: OracleColumn.describe_null
172-
173-
This read-only property returns the description of the null representation
174-
that the column uses.
175-
176-
.. attribute:: OracleColumn.dtype
177-
178-
This read-only attribute returns the Dtype description as a tuple
179-
containing the values for the attributes ``kind``, ``bit-width``,
180-
``format string``, and ``endianess``.
181-
182-
The ``kind`` attribute specifies the type of the data.
183-
184-
The ``bit-width`` attribute specifies the number of bits as an integer.
185-
186-
The ``format string`` attribute specifies the data type description format
187-
string in Apache Arrow C Data Interface format.
188-
189-
The ``endianess`` attribute specifies the byte order of the data type.
190-
Currently, only native endianess is supported.
191-
192-
.. attribute:: OracleColumn.metadata
193-
194-
This read-only attribute returns the metadata for the column as a
195-
dictionary with string keys.
196-
197-
.. attribute:: OracleColumn.null_count
198-
199-
This read-only attribute returns the number of null row values, if known.
200-
201-
.. attribute:: OracleColumn.offset
202-
203-
This read-only attribute specifies the offset of the first row.
204-
205-
.. _oraclecolumnbufferobj:
206-
207-
OracleColumnBuffer Objects
208-
==========================
209-
210-
A buffer object backed by an ArrowArray consisting of a single chunk.
211-
212-
This is an internal class used for conversion to third party data frames.
213-
214-
.. versionadded:: 3.0.0
215-
216-
.. _oraclecolumnbufferattr:
217-
218-
OracleColumnBuffer Attributes
219-
-----------------------------
220-
221-
.. attribute:: OracleColumnBuffer.bufsize
222-
223-
This read-only property returns the buffer size in bytes.
224-
225-
.. attribute:: OracleColumnBuffer.ptr
226-
227-
This read-only attribute specifies the pointer to the start of the buffer
228-
as an integer.

doc/src/release_notes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ Thick Mode Changes
3333
Common Changes
3434
++++++++++++++
3535

36+
#) Changes to :ref:`data frame <dataframeformat>` support:
37+
38+
- Remove use of the DataFrame Interchange Protocol in
39+
:ref:`OracleDataFrames <oracledataframeobj>`.
40+
- Documentation on methods and attributes on the ``DataFrame`` and
41+
``ArrowArray`` objects are now available in Python plugins such as those
42+
found in VS Code
43+
44+
Note the data frame support in python-oracledb 3.3 is a pre-release, and
45+
may change in a future version
3646

3747
oracledb `3.2.0 <https://github.com/oracle/python-oracledb/compare/v3.1.1...v3.2.0>`__ (June 2025)
3848
--------------------------------------------------------------------------------------------------

doc/src/user_guide/dataframes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ frame objects of other libraries.
1818

1919
.. note::
2020

21-
The data frame support in python-oracledb 3.2 is a pre-release and may
21+
The data frame support in python-oracledb 3.3 is a pre-release and may
2222
change in a future version.
2323

2424
**Fetching Data Frames**

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ test_suite = tests
4444
packages =
4545
oracledb
4646
oracledb.plugins
47-
oracledb.interchange
4847
package_dir =
4948
=src
5049

setup.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@
3131
# base source directory
3232
source_dir = os.path.join("src", "oracledb")
3333

34-
# determine the nanoarrow bridge dependent source files (included)
35-
base_dir = os.path.join(source_dir, "interchange")
36-
nanoarrow_bridge_depends = [
37-
os.path.join(base_dir, "nanoarrow", "nanoarrow.c"),
38-
os.path.join(base_dir, "nanoarrow", "nanoarrow.h"),
34+
# determine the Arrow dependent source files (included)
35+
impl_dir = os.path.join(source_dir, "impl", "arrow")
36+
nanoarrow_include_dir = os.path.join(impl_dir, "nanoarrow")
37+
arrow_depends = [
38+
os.path.join(impl_dir, n)
39+
for n in sorted(os.listdir(impl_dir))
40+
if n.endswith(".pyx") or n.endswith(".pxi") or n.endswith(".pxd")
3941
]
40-
nanoarrow_bridge_pxd = os.path.join(base_dir, "nanoarrow_bridge.pxd")
42+
arrow_depends.append(os.path.join(nanoarrow_include_dir, "nanoarrow.c"))
43+
arrow_depends.append(os.path.join(nanoarrow_include_dir, "nanoarrow.h"))
44+
arrow_pxd = os.path.join(source_dir, "arrow_impl.pxd")
45+
arrow_depends.append(arrow_pxd)
4146

4247
# determine the base implementation dependent source files (included)
4348
impl_dir = os.path.join(source_dir, "impl", "base")
@@ -47,7 +52,7 @@
4752
if n.endswith(".pyx")
4853
]
4954
base_pxd = os.path.join(source_dir, "base_impl.pxd")
50-
base_depends.extend([base_pxd, nanoarrow_bridge_pxd])
55+
base_depends.extend([base_pxd, arrow_pxd])
5156

5257
# determine the thick mode dependent source files (included)
5358
impl_dir = os.path.join(source_dir, "impl", "thick")
@@ -77,6 +82,7 @@
7782
]
7883
thin_depends.append(base_pxd)
7984

85+
8086
# if the platform is macOS:
8187
# - target the minimum OS version that current Python packages work with.
8288
# (Use 'otool -l /path/to/python' and look for 'version' in the
@@ -99,14 +105,14 @@
99105
Extension(
100106
"oracledb.base_impl",
101107
sources=["src/oracledb/base_impl.pyx"],
102-
include_dirs=["src/oracledb/interchange/nanoarrow"],
108+
include_dirs=[nanoarrow_include_dir],
103109
depends=base_depends,
104110
extra_compile_args=extra_compile_args,
105111
),
106112
Extension(
107113
"oracledb.thin_impl",
108114
sources=["src/oracledb/thin_impl.pyx"],
109-
include_dirs=["src/oracledb/interchange/nanoarrow"],
115+
include_dirs=[nanoarrow_include_dir],
110116
depends=thin_depends,
111117
extra_compile_args=extra_compile_args,
112118
),
@@ -115,16 +121,16 @@
115121
sources=["src/oracledb/thick_impl.pyx"],
116122
include_dirs=[
117123
"src/oracledb/impl/thick/odpi/include",
118-
"src/oracledb/interchange/nanoarrow",
124+
nanoarrow_include_dir,
119125
],
120126
depends=thick_depends,
121127
extra_compile_args=extra_compile_args,
122128
),
123129
Extension(
124-
"oracledb.interchange.nanoarrow_bridge",
125-
sources=["src/oracledb/interchange/nanoarrow_bridge.pyx"],
126-
include_dirs=["src/oracledb/interchange/nanoarrow"],
127-
depends=nanoarrow_bridge_depends,
130+
"oracledb.arrow_impl",
131+
sources=["src/oracledb/arrow_impl.pyx"],
132+
include_dirs=[nanoarrow_include_dir],
133+
depends=arrow_depends,
128134
extra_compile_args=extra_compile_args,
129135
),
130136
]

src/oracledb/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,12 @@
316316
SparseVector as SparseVector,
317317
)
318318

319-
from .interchange.dataframe import (
320-
OracleDataFrame as OracleDataFrame,
319+
from .arrow_array import (
320+
ArrowArray as ArrowArray,
321+
)
322+
323+
from .dataframe import (
324+
DataFrame as DataFrame,
321325
)
322326

323327
from . import builtin_hooks

0 commit comments

Comments
 (0)