Skip to main content

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

Project description

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 for to_pandas()

When configured with an Arrow encoding, to_pandas() uses Arrow IPC spooling with parallel segment decoding for significantly faster pandas DataFrame creation.

pip install pystarburst[pyarrow]
from pystarburst import Session

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

df = session.sql("SELECT * FROM nation").to_pandas()

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pystarburst-0.12.0-py3-none-any.whl (137.3 kB view details)

Uploaded Python 3

File details

Details for the file pystarburst-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: pystarburst-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 137.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for pystarburst-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaeb3c1580997d166b36b768844ecd15fa425f532f19efa87434b8e269175983
MD5 c8fe96bf924af955b616d04723028f8a
BLAKE2b-256 077259fd9140a602c924346d23831138ab4487a74eac173d4741d4368dddb6a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page