Skip to main content

Simple tool to query Dremio with Apache Arrow Flight

Project description

dremio_simple_query

The purpose of this library is to easily query a Dremio source using Arrow Flight for analytics.

LEARN MORE ABOUT DREMIO

Use Dremio to Help:

  • Govern your data
  • Join your data across sources (Iceberg, Delta, S3, JSON, CSV, RDBMS, and more)
  • Accelerate your queries across data sources
  • Reduce your Data Warehouse Workloads

With this library your analysts can more easily get their data from Dremio and easily get to work running local analytics with Arrow and DuckDB. This library can grab large datasets performantly thanks to using Apache Arrow Flight.

Setting up your connection

from dremio_simple_query.connect import DremioConnection
from os import getenv
from dotenv import load_dotenv

load_dotenv()

## Dremio Person Token
token = getenv("TOKEN")

## Arrow Endpoint (See Dremio Documentation)
uri = getenv("ARROW_ENDPOINT")

## Create Dremio Arrow Connection
dremio = DremioConnection(token, uri)

Query (Get Arrow Back)

If you want to get Arrow Data back you can run a query like so.

stream = dremio.toArrow("SELECT * FROM arctic.table1;")

The .toArrow method returns a FlightStreamReader object which can be converted into typical Arrow objects.

Arrow Table

arrow_table = stream.read_all()

Arrow RecordBatchReader

batch_reader = stream.to_reader()

Pandas Dataframe

df = stream.read_pandas()

Querying with DuckDB

Using the DuckDB Relation API

Using the .toDuckDB method the query results will be returned as a DuckDB relation.

duck_rel = dremio.toDuckDB("SELECT * FROM arctic.table1")

result = duck_rel.query("table1", "SELECT * from table1").fetchall()

result2 = duck_rel.filter

print(result)

Querying Arrow Objects with DuckDB

from dremio_simple_query.connect import DremioConnection
from os import getenv
from dotenv import load_dotenv
import duckdb

## DuckDB Connection
con = duckdb.connection()

load_dotenv()

## Dremio Person Token
token = getenv("TOKEN")

## Arrow Endpoint (See Dremio Documentation)
uri = getenv("ARROW_ENDPOINT")

## Create Dremio Arrow Connection
dremio = DremioConnection(token, uri)

## Get Data from Dremio
stream = dremio.toArrow("SELECT * FROM arctic.table1;")

## Turn into Arrow Table
my_table = stream.read_all()

## Query with Duckdb
results = con.execute("SELECT * FROM my_table;").fetchall()

print(results)

Project details


Download files

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

Source Distribution

dremio_simple_query-0.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

dremio_simple_query-0.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file dremio_simple_query-0.0.2.tar.gz.

File metadata

  • Download URL: dremio_simple_query-0.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.0

File hashes

Hashes for dremio_simple_query-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f96128d7d5a384aa3b014c268eaf9e8b5f87ced51810550cfb4a8f13cff51c03
MD5 491ebce5df8e5aacda9037a19a80139e
BLAKE2b-256 c1effda8ea3031c2d35b9cfedefc509ebe0213d62bd268d803e06431ecc49bd2

See more details on using hashes here.

File details

Details for the file dremio_simple_query-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dremio_simple_query-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3582f344ca898dd9cf5e608889873e9634648e68e36a30023ee43ef7ee97a99d
MD5 9bd43f1e0e4bfd331fff90b28775944c
BLAKE2b-256 680f31ce9244faa254d17fcf954eda9d421c7b8efc0c725625ebb0c57a3995cf

See more details on using hashes here.

Supported by

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