Converting pydantic classes to spark schemas
Project description
pydantic-spark
This library can convert a pydantic class to a spark schema or generate python code from a spark schema.
Install
pip install pydantic-spark
Pydantic class to spark schema
import json
from typing import Optional
from pydantic_spark.base import SparkBase
class TestModel(SparkBase):
key1: str
key2: int
key2: Optional[str]
schema_dict: dict = TestModel.spark_schema()
print(json.dumps(schema_dict))
Install for developers
Install package
- Requirement: Poetry 1.*
poetry install
Run unit tests
pytest
coverage run -m pytest # with coverage
# or (depends on your local env)
poetry run pytest
poetry run coverage run -m pytest # with coverage
Run linting
The linting is checked in the github workflow. To fix and review issues run this:
black . # Auto fix all issues
isort . # Auto fix all issues
pflake . # Only display issues, fixing is manual
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
pydantic-spark-0.2.0.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file pydantic-spark-0.2.0.tar.gz
.
File metadata
- Download URL: pydantic-spark-0.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.9.1 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58a556d220fd19f8dd21ebdd57746b6191e52152087ea72e1338060f47623e1a |
|
MD5 | 8420c618f3b4f1c0dd9daf8aa2ca5dcf |
|
BLAKE2b-256 | 4b320cd2dda3055e8af63c34b5bfcc330f58ac567981fe1e23442eb4090f3283 |
File details
Details for the file pydantic_spark-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: pydantic_spark-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.9.1 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27556bf33304e62c8e15a7b13d61cb5ec317e1ef8892f1085fd6d7ec6d6c9a7e |
|
MD5 | 9753beb1fb59400fdc33ca9dd79eee90 |
|
BLAKE2b-256 | c0b061b53482594fb2b601bce99565f6d7f9fd69a329202e4e8049172d97cf71 |