Skip to main content

PyStarburst DataFrame API

PyStarburst DataFrame API allows you to query and transform data in Starburst products in a data pipeline without having to download the data locally.

Documentation

See the PyStarburst API documentation and the examples repository.

Getting started

Install pystarburst

pip install pystarburst

Connect to a Starburst server

The parameters are the same connect parameters as in Trino Python Client.

from pystarburst import Session

connection_parameters = {
    "host": "localhost",
    "port": 8080,
    "user": "admin",
    "catalog": "tpch",
    "schema": "tiny"
}

session = Session.builder.configs(connection_parameters).create()

Using SQL

from pystarburst import Session

session = Session.builder.configs({ ... }).create()

session.sql("SELECT 1 as a").show()

Querying a table

from pystarburst import Session

session = Session.builder.configs({ ... }).create()

df = session.table("nation")
print(df.schema)
df.show()

Filtering a data frame

from pystarburst import Session

session = Session.builder.configs({ ... }).create()

df = session.table("nation")
df.filter(df.col("regionkey") == 0).show()

Joining data frames

from pystarburst import Session

session = Session.builder.configs({ ... }).create()

df = session.table("nation")
df.filter(df.col("regionkey") == 0).show()

Aggregation

from pystarburst import Session
from pystarburst.functions import col

session = Session.builder.configs({ ... }).create()
df = session.table("nation")
df.agg((col("regionkey"), "max"), (col("regionkey"), "avg")).show()

Arrow spooling

With a server configured to use Arrow encoding, DataFrame methods to_arrow_batches(), to_arrow_table() and to_pandas() use Arrow IPC spooling with parallel segment decoding for significantly faster transfer of large result sets.

pip install pystarburst[pyarrow]
from pystarburst import Session

session = Session.builder.configs({...}).create()

pandas_df = session.sql("SELECT * FROM nation").to_pandas()
# or
arrow_reader = session.sql("SELECT * FROM nation").to_arrow_batches()
# or
arrow_table = session.sql("SELECT * FROM nation").to_arrow_table()

Of the three methods: to_arrow_batches(), to_arrow_table() and to_pandas(), to_arrow_batches() is the most memory efficient, as it returns pyarrow.RecordBatchReader that can iterate over record batches without materializing the entire result set in memory.

Arrow encoding is used only for those three methods. All other operations (collect(), show(), etc.) use the default encoding.

By default, PyStarburst requests Arrow encodings arrow+zstd, arrow+lz4 and arrow, in that order, from the server. The property arrow_encoding may be used to override encoding preferences. For example, to prefer uncompressed Arrow data but accept zstd-compressed if the server does not support uncompressed Arrow, set arrow_encoding as follows:

session = Session.builder.configs({"arrow_encoding": "arrow,arrow+zstd", ...}).create()

Metadata

Release files for pystarburst 0.17.0

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

Built distribution (wheel)

Table of built distributions (wheels) for pystarburst 0.17.0
File Interpreter ABI Platform Actions
pystarburst-0.17.0-py3-none-any.whl Python 3 none any Details for pystarburst-0.17.0-py3-none-any.whl

Release files / pystarburst-0.17.0-py3-none-any.whl

Download URL pystarburst-0.17.0-py3-none-any.whl
Size 141.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7332edc6eb12d6237fa71adb1b7cf57e829920318fef3fd69dd02d0b3de123ca
BLAKE2b-256 checksum
How to use checksums
5b361a07256f82f9e952a792aebbe1d187b7f4efac9e8daaeb0585bedaaf2438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.14.10

Security for pystarburst 0.17.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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