GraphQL service for arrow tables and parquet files.
Project description
GraphQL service for arrow tables and parquet files. The schema is derived automatically.
Usage
% env PARQUET_PATH=... uvicorn graphique.service:app [--reload]
Open http://localhost:8000/graphql to try out the API in GraphiQL.
There is a test fixture at ./tests/fixtures/zipcodes.parquet
.
Configuration
Graphique uses Starlette's config: in environment variables or a .env
file.
Config variables are used as input to ParquetDataset.
- COLUMNS = None
- DEBUG = False
- DICTIONARIES = None
- INDEX = None
- MMAP = True
- PARQUET_PATH
Queries
A Table
is the primary interface. It has fields for filtering, sorting, and grouping.
"""a column-oriented table"""
type Table {
"""number of rows"""
length: Long!
"""fields for each column"""
columns: Columns!
"""Return scalar values at index."""
row(index: Long! = 0): Row!
"""Return table slice."""
slice(offset: Long! = 0, length: Long): Table!
"""
Return tables grouped by columns, with stable ordering.
`length` is the maximum number of tables to return.
`count` filters and sorts tables based on the number of rows within each table.
"""
group(by: [String!]!, reverse: Boolean! = false, length: Long, count: LongReduce): [Table!]!
"""
Return table of first or last occurrences grouped by columns, with stable ordering.
"""
unique(by: [String!]!, reverse: Boolean! = false): Table!
"""Return table slice sorted by specified columns."""
sort(by: [String!]!, reverse: Boolean! = false, length: Long): Table!
"""Return table with minimum values per column."""
min(by: [String!]!): Table!
"""Return table with maximum values per column."""
max(by: [String!]!): Table!
"""
Return table with rows which match all (by default) queries.
`invert` optionally excludes matching rows.
`reduce` is the binary operator to combine filters; within a column all predicates must match.
"""
filter(query: Filters!, invert: Boolean! = false, reduce: Operator! = AND): Table!
Performance
Graphique relies on native pyarrow routines wherever possible. Otherwise it falls back to using NumPy, with zero-copy views. Graphique also has custom optimizations for grouping, dictionary-encoded arrays, and chunked arrays.
Specifying an INDEX
of columns indicates the table is sorted, and enables a binary search interface.
"""
Return table with matching values for compound `index`.
Queries must be a prefix of the `index`.
Only one non-equal query is allowed, and applied last.
"""
search(...): Table!
Installation
% pip install graphique
Dependencies
- pyarrow >=1
- strawberry-graphql >=0.30
- pytz (optional timestamp support)
Tests
100% branch coverage.
% pytest [--cov]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for graphique-0.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79a4dfe5daf749148ed3381b148e43c81ece0603d1190c7e48b257f405af30fc |
|
MD5 | e26160745343f2fc3838fc236555a33b |
|
BLAKE2b-256 | f51ea40bb8073c82416ca513540dc0fc9e11f57537f9e905c9da8c07c24beebf |
Hashes for graphique-0.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36738e89743d8ac53fa0db8bd9de10baf4adefb73cc022c9c9b3cf76c3b83d35 |
|
MD5 | 55377ca1a9e97b36b8000bd0ecc1436b |
|
BLAKE2b-256 | 8c4441bd3492bfaca42e96cf22d296d8d480901fc6d89041e62fcbf0b131f22d |
Hashes for graphique-0.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 183d0e9a6e36ab7abb23c37e0dddaaa9efd109edf73393c3aac7927b459d798e |
|
MD5 | 9cb5ebc80900892858e0cc7862aad644 |
|
BLAKE2b-256 | dc49e694c1fbe3ea984a8dc6229f12bf6aa096f998a145af8b8424c0070d41f5 |