Skip to main content

arrow2xmla

Arrow in, XMLA out.
Write the cellsets an OLAP client such as Excel's PivotTable reads, straight from columnar data, and parse its requests.
Cellsets, rowsets, SOAP envelopes and faults from Arrow, request parsing, streaming output.
Pure Rust core · Python binding · no engine, no catalog, no runtime dependencies.

CI License: MIT Python 3.10+ Rust 1.88+


Speed

A pivot of 490 000 rows × 3 measures is 296 MB of XML. arrow2xmla writes it in 23 ms.

490 000 rows × 3 measures (296 MB) Time Throughput vs pure Python
Pure-Python writer (tests/reference.py) 1 287 ms 0.23 GB/s 1×
arrow2xmla, 1 thread 81 ms 3.6 GB/s 16×
arrow2xmla, all cores (threads=0) 23 ms 12.8 GB/s 57×

More cases (uv run pytest benchmarks --benchmark-only, mean time per call):

Case Answer Time
60 000 rows × 1 float 25 MB 1.5 ms
60 000 rows × 3 mixed (float, int, text) 38 MB 2.4 ms
60 000 rows × 3, every value needs escaping 42 MB 3.2 ms
490 000 rows × 3 mixed 316 MB 21 ms
Parse a real Excel request – ≈ 4 µs (23 recorded requests: 0.1 ms)
Parse a request with a large MDX statement – ≈ 0.3 ms

Apple M-series, 12 cores, Python 3.14, best of several runs. The pure-Python writer is a plain, readable reference implementation, not a tuned one: it is the oracle the tests compare every byte against. Reproduce with uv run python tests/bench_cellset.py 490000 and uv run pytest benchmarks --benchmark-only (add --benchmark-save=NAME / --benchmark-compare to track a change).

Why it is fast. Rows are rendered straight from the Arrow buffers into byte chunks, in parallel, with no per-value objects: integers through itoa, floats through zmij (Python's shortest repr, laid out for XML), text copied when it needs no escaping. A level's members are written from the text column with no member object built per value. Many answers written at once share the cores (threads=0 never takes more than are free), so a web server does not oversubscribe.

And small. The Python extension is 494 KB, the wheel 261 KB (uv run python benchmarks/size.py). There are no Arrow crates in it: arrays are read through the Arrow C interface.


Install

pip install arrow2xmla

Python 3.10+, one abi3 wheel per platform (Linux, macOS, Windows). pyarrow is optional: any library that exports the Arrow PyCapsule interface works (pyarrow, nanoarrow, ...; a polars Series goes through pyarrow, or .to_arrow() it first).

# Cargo.toml (Rust 1.88+)
arrow2xmla = "0.2"

Quick start

Abridged from examples/quickstart.py, which runs as it is (the snippet leaves out the request body).

import pyarrow as pa
from arrow2xmla import CellValues, Cellset, Discover, Execute, LevelAxis, Member, MemberProperty, MemberType, TupleAxis, parse_request

# the rows: one member per customer, read straight from an Arrow text column (nothing is built per value)
customers = pa.array(["Acme", "Globex", None, "Initech & Co"])
customer = Member("[Customer].[Name]", "[Customer].[Name].[Name]", 1, parent_unique_name="[Customer].[Name].[All]")
all_customers = Member("[Customer].[Name]", "[Customer].[Name].[(All)]", 0, "[Customer].[Name].[All]", "All", member_type=MemberType.ALL)

# the columns: two measures, listed once
measure = lambda name: Member("[Measures]", "[Measures].[MeasuresLevel]", 0, f"[Measures].[{name}]", name, member_type=MemberType.MEASURE)

cellset = Cellset(
    cube="Sales",
    columns_axis=TupleAxis.from_tuples([[measure("Revenue")], [measure("Orders")]]),
    rows_axis=LevelAxis(customer, customers, all=all_customers, properties=[MemberProperty.MEMBER_CAPTION]),
    # one array per column of cells, in the order of the columns axis; a null is an empty cell
    values=[
        CellValues(pa.array([1500.5, 920.0, None, 77.25, 12.0]), "#,##0.00"),  # the All row, then the customers
        CellValues(pa.array([30, 12, 1, 4, 2]), "0"),
    ],
)
xml = cellset.to_xml()          # bytes: an XMLA MDDataset, for the body of an Execute response

request = parse_request(body)   # body: the bytes of the HTTP request
match request.call:
    case Execute(statement=mdx): ...
    case Discover(request_type=kind): ...

In Rust

crates/arrow2xmla/examples/basic.rs: the same model over zero-copy Arrays.

let mut rows = Axis::level(LevelAxis::new(customer, Array::new(Values::Utf8 { offsets: &offsets, data: &data })));
rows.properties = vec![MemberProp::MemberCaption];

let mut cellset = Cellset::new("Sales");
cellset.axes = vec![columns, rows];
cellset.columns.push(Column::new(Array::new(Values::F64(&amounts)), "#,##0.00"));

let xml = cellset.to_vec()?;   // or cellset.write_to(&mut writer), or write_chunks(..) for a stream of ~1 MB chunks

A server

The three writers (cellset, rowset, fault) and the envelope are all a server needs next to parse_request; what it answers with is up to it. This is the shape of one (the mock endpoint in tests/e2e/xmla_mock.py is a complete one, read by olap4j in the tests):

import itertools
import pyarrow as pa
import arrow2xmla as ax

def answer(body: bytes):
    """-> (HTTP status, an iterable of bytes)"""
    try:
        request = ax.parse_request(body, max_size=1 << 20)
    except ax.XmlaError as e:
        return 500, [ax.fault(str(e))]
    session = "new-id" if request.session.kind is ax.SessionKind.BEGIN else request.session.id
    match request.call:
        case ax.Discover(request_type="MDSCHEMA_CUBES"):
            rows = ax.Rowset.from_columns({"CUBE_NAME": pa.array(["Sales"]), "CUBE_TYPE": pa.array(["CUBE"])})
            return 200, [ax.Envelope(ax.Method.DISCOVER, session).wrap(rows.to_xml())]
        case ax.Execute(statement=mdx):
            envelope = ax.Envelope(ax.Method.EXECUTE, session)
            cellset = run(mdx)  # your engine: an ax.Cellset over its Arrow results
            return 200, itertools.chain([envelope.head()], cellset.iter_xml(), [envelope.tail()])   # lazy: ~1 MB in memory
    return 500, [ax.fault("not supported", session=session)]

Streaming

to_xml() builds the whole answer (about twice its size in memory at the peak). For a big one:

with open("answer.xml", "wb") as fp:
    cellset.write_to(fp)          # chunks of ~1 MB as they are made

for chunk in cellset.iter_xml():  # or as an iterator, written ahead on another thread (e.g. a streaming response)
    ...
330 MB answer (600 000 rows × 3 measures) Memory the process grows by
to_xml() 630 MB
write_to(sink) / iter_xml() 22 MB

Everything that can be checked is checked before the first chunk, so a response that streams does not start with an invalid cellset; an error of the sink itself (a closed socket) is raised as it is, mid-stream. A sink that takes part of a chunk is offered the rest; closing or dropping the iterator stops the writer.

The model

Piece What it is
Member One member: a value of a field, its All member, a measure. MemberType says which.
LevelAxis The values of one level, read from an Arrow text column. The fast form for big axes: unique name <hierarchy>.&[key] and caption are made from the key; a null key is the blank member. Optional All member.
TupleAxis Explicit tuples: the distinct members once, each tuple as indices into them. from_tuples builds one from tuples of members. DISPLAY_INFO (children, drilled down, same parent) is worked out for you.
CellValues One column of cells: an Arrow array and its number format. A null is a cell with no value.
Rowset The answer to a Discover: Arrow columns written with the schema block clients read the column types from (RowsetColumn to override a type, e.g. xsd:boolean).
Envelope, fault The SOAP around an answer (head() / tail() for a streamed one), and the fault for a request that failed.
Cellset The answer to an MDX Execute: a cube name, the axes, the cell columns, an optional slicer (WHERE), the cell properties and the language.

A cell's ordinal is row * len(values) + column. The axes must list exactly those cells, or the call is refused before a byte is written:

  • columns_axis and rows_axis: the first lists the columns, the second the rows.
  • Only columns_axis: it lists rows * len(values) tuples, the cells in order.
  • Neither: at most one cell (SELECT FROM [Cube] WHERE ...).
  • rows_axis alone, or more than two axes: refused.

Data types

Arrow type Written as
int8 … int64, uint8 … uint64 xsd:int; xsd:long / xsd:unsignedLong when 32 bits do not hold the value
float16, float32, float64 xsd:double, Python's shortest repr digits; NaN, INF, -INF
string, large_string, string_view xsd:string, escaped
null no value: the cell is left out
anything else (bool, dates, decimals, dictionaries, ...) refused with UnsupportedTypeError: cast it first

Characters XML 1.0 forbids are replaced with U+FFFD, so Excel's parser accepts the answer. Chunked arrays are combined first. Only VALUE, FORMAT_STRING and LANGUAGE are written in a cell (CellProperty); a property that is not written is not accepted, rather than silently left blank.

Requests

parse_request(body, max_size=4 MiB) reads a SOAP envelope holding a Discover or an Execute (UTF-8, or UTF-16 with a BOM) into frozen dataclasses you can match on: Request(session, call), with Session, Discover (request_type, restrictions, properties), Execute (statement, properties) and Other.

It is strict and safe for bodies from the network: no DOCTYPE is ever accepted (no entity expansion), nesting and the number of elements are bounded, a longer body than max_size is refused before it is read, and what a strict XML parser refuses is refused (a second root, text outside the root, an undeclared prefix, characters XML forbids).

Errors

Everything this package refuses derives from XmlaError (a ValueError):

XmlaError
├── CellsetError              an invalid cellset: shapes that do not add up, bad arrays, unknown names
│   └── UnsupportedTypeError  an Arrow type that is not written
└── RequestError              a request that is not accepted
    ├── DoctypeError
    └── RequestTooLarge

A wrong Python type (a str where a Member belongs) is a plain TypeError. Cellset.from_dict({...}) builds a cellset from plain data (JSON, a config); an unknown key is an error.

Trust

  • Request bodies are untrusted: see above. Lower max_size for a public endpoint.
  • Arrow arrays are trusted. The Arrow C data interface does not say how long a buffer is, so a variable-size array's extent is read from its own offsets. The binding refuses what the structs themselves show to be wrong (negative lengths, missing buffers, released arrays, offsets that overrun) with an error and never a crash, and the core checks offsets, UTF-8 and view bounds before writing. It is not a validator for hostile Arrow memory; see SECURITY.md.

Correctness

The output is byte-identical to a plain Python implementation, which is what the tests hold it to:

  • Parity: random and hand-picked cellsets (all dtypes, escapes, nulls, display info, slicers, 1–3 threads) against tests/reference.py; the request parser against Python's expat + ElementTree on recorded real Excel requests (tests/fixtures/excel). The one deliberate difference is U+FFFD for characters XML forbids.
  • Hardening: a data-type matrix, hostile C-interface structs in a subprocess (it must error, never crash), number forms at their boundaries, and a strict-parser suite.
  • Contract: every name the Python enums know is known to the Rust core.
  • End to end: a mock XMLA endpoint over real HTTP (tests/e2e) replays the recorded Excel requests; a mock client reads each answer the way a pivot client does (strict XML, axes as tuples, cells by ordinal, typed by xsi:type) and checks the grid against the data, including nulls, escaping, sessions, faults on bad requests and 200 000 rows from concurrent callers.
  • Independent client: olap4j's XMLA driver (Java) connects to that endpoint, runs MDX and reads the pivot back: axes, members, typed cells and nulls. The cellset is also validated against Microsoft's mddataset schema.

Real Excel for Windows is the one client that cannot be run in CI: the request fixtures are recordings of it, and the mock client stands in for it.

What Excel sends and expects, from the recorded session: docs/EXCEL-XMLA.md. Changes: CHANGELOG.md.

Not built yet

An MDX parser and evaluator (the engine's job), binary XML (sx) and Xpress compression, which MSOLAP can negotiate (plain XML is accepted), and the rowsets' content: what MDSCHEMA_CUBES and friends hold is the server's catalog, written with Rowset. Real Excel and Power BI are untested (docs/EXCEL-XMLA.md).

Develop

cargo test                                   # Rust unit tests
uv sync && uv run maturin develop -r         # build the Python module
uv run pytest                                # parity, data types, hardening, contract
uv run pytest benchmarks --benchmark-only    # speed
uv run python benchmarks/size.py             # size of the module and the wheel
cargo run -p arrow2xmla --example basic      # the Rust example

CI (.github/workflows/workflow.yml) runs clippy and the tests, builds wheels for Linux (glibc, musl, arm64), macOS (Intel, Apple silicon) and Windows, and publishes to PyPI on a v* tag.

License

MIT

Metadata

Release files for arrow2xmla 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arrow2xmla 0.2.0
File Size Uploaded Provenance Actions
arrow2xmla-0.2.0.tar.gz 62.8 kB With provenance Details for arrow2xmla-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for arrow2xmla 0.2.0
File Actions
arrow2xmla-0.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for arrow2xmla-0.2.0-cp310-abi3-win_amd64.whl
arrow2xmla-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for arrow2xmla-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
arrow2xmla-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for arrow2xmla-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
arrow2xmla-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for arrow2xmla-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
arrow2xmla-0.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for arrow2xmla-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
arrow2xmla-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for arrow2xmla-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 2.0 MB

Release files / arrow2xmla-0.2.0.tar.gz

Download URL arrow2xmla-0.2.0.tar.gz
Size 62.8 kB
Tags Source
SHA-256 checksum
How to use checksums
addef5708cfbdf57116beda3e762953770a73c0a6e2ceef36d8daf8da3a73cd1
BLAKE2b-256 checksum
How to use checksums
5c11746a92ca7d6d53cab5065dc300a5ab239f202a3ecae61fab9b87bedc8d9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / arrow2xmla-0.2.0-cp310-abi3-win_amd64.whl

Download URL arrow2xmla-0.2.0-cp310-abi3-win_amd64.whl
Size 221.6 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7030dd08e4017ae935ba182581d75e1057c33d48f68cee9cc07d41c16e98c38f
BLAKE2b-256 checksum
How to use checksums
1e08efed5e7fab6068b0dffaa0ab90cc302ffeb17f0908cd08f24c853aa2386e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / arrow2xmla-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL arrow2xmla-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 519.7 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
e273015e72c3d254bf9441814c55ecb88731042741027f34c702c59e7ade8e33
BLAKE2b-256 checksum
How to use checksums
d18cf8e5d8088b45b7afeb5ab3dab17cbc431b2c6fc44294b86102c52d465f6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / arrow2xmla-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL arrow2xmla-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 306.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
52e16b9b446bf394adae3b5af7379e8fb3f42350ef41b378cc7ecf446b114f0f
BLAKE2b-256 checksum
How to use checksums
16784195504476a2c7657d6d48fc58f62bbeb2c05824a2fc3bcfd100be5dc6de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / arrow2xmla-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL arrow2xmla-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 299.1 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d8a29de3bb00767eb2cff4bb4f0692fe425f054340524ec9575f0922b8b6ca34
BLAKE2b-256 checksum
How to use checksums
af03e4e748036cab23b96a14a41afb33e015e531b2f36f69c3d66c3f0bb3c891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / arrow2xmla-0.2.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL arrow2xmla-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 283.1 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8507f3a449c555d0f97570ceace11df46768ab6b03e3f9d410fc60c7e402e523
BLAKE2b-256 checksum
How to use checksums
8e75daab403a0d54d9542c3a29a50f8e5942a89ce1cc4f2de6df170a5e550738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / arrow2xmla-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL arrow2xmla-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 285.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9061df0434e311f9d12feaafd5c7678ad0c36fa8e28c9370bf1a7e6a5311c025
BLAKE2b-256 checksum
How to use checksums
2b1f8e433c0ff3bd6970ff721ebb79808b778afb0032f5fadbf8529e12d924cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for arrow2xmla 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for arrow2xmla-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

7 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page