aws-parquet
aws-parquet is a toolkit than enables working with parquet datasets on AWS. It handles AWS S3 reads/writes, AWS Glue catalog updates and AWS Athena queries by providing a simple and intuitive interface.
Motivation
The goal is to provide a simple and intuitive interface to create and manage parquet datasets on AWS.
aws-parquet makes use of the following tools:
- awswrangler as an AWS SDK for pandas
- pandera for pandas-based data validation
- typeguard and pydantic for runtime type checking
Features
aws-parquet provides a ParquetDataset class that enables the following operations:
- create a parquet dataset that will get registered in AWS Glue
- append new data to the dataset and update the AWS Glue catalog
- read a partition of the dataset and perform proper schema validation and type casting
- overwrite data in the dataset after performing proper schema validation and type casting
- delete a partition of the dataset and update the AWS Glue catalog
- query the dataset using AWS Athena
How to setup
Using pip:
pip install aws_parquet
How to use
Create a parquet dataset that will get registered in AWS Glue
import os
from aws_parquet import ParquetDataset
import pandas as pd
import pandera as pa
from pandera.typing import Series
# define your pandera schema model
class MyDatasetSchemaModel(pa.SchemaModel):
col1: Series[int] = pa.Field(nullable=False, ge=0, lt=10)
col2: Series[pa.DateTime]
col3: Series[float]
# configuration
database = "default"
bucket_name = os.environ["AWS_S3_BUCKET"]
table_name = "foo_bar"
path = f"s3://{bucket_name}/{table_name}/"
partition_cols = ["col1", "col2"]
schema = MyDatasetSchemaModel.to_schema()
# create the dataset
dataset = ParquetDataset(
database=database,
table=table_name,
partition_cols=partition_cols,
path=path,
pandera_schema=schema,
)
dataset.create()
Append new data to the dataset
df = pd.DataFrame({
"col1": [1, 2, 3],
"col2": ["2021-01-01", "2021-01-02", "2021-01-03"],
"col3": [1.0, 2.0, 3.0]
})
dataset.update(df)
Read a partition of the dataset
df = dataset.read({"col2": "2021-01-01"})
Overwrite data in the dataset
df_overwrite = pd.DataFrame({
"col1": [1, 2, 3],
"col2": ["2021-01-01", "2021-01-02", "2021-01-03"],
"col3": [4.0, 5.0, 6.0]
})
dataset.update(df_overwrite, overwrite=True)
Query the dataset using AWS Athena
df = dataset.query("SELECT col1 FROM foo_bar")
Delete a partition of the dataset
dataset.delete({"col1": 1, "col2": "2021-01-01"})
Delete the dataset in its entirety
dataset.delete()
Metadata
Release files for aws-parquet 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aws_parquet-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for aws_parquet-0.5.0-py3-none-any.whl |
Release files / aws_parquet-0.5.0-py3-none-any.whl
| Download URL | aws_parquet-0.5.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9ec49bf2f11c73cab98e1d186c1fc118496681c33a62914cd52365932734be2
|
|
BLAKE2b-256 checksum How to use checksums |
f72ec5b657fda0e9be441f9c941fe42ba992587145c72287c96db351dd9d278b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.8.7 Darwin/22.5.0
|
Security for aws-parquet 0.5.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.