Spark DDL Parser
Spark DDL Parser turns Spark SQL schema strings into structured Python or Rust values. It parses schema declarations; it does not run SQL or require Spark.
The Python package has no runtime dependencies and requires Python 3.11 or newer. This repository also contains a Rust crate, which requires Rust 1.78 or newer.
Python
Install from PyPI:
python -m pip install spark-ddl-parser
Parse a schema and inspect its fields:
from spark_ddl_parser import parse_ddl_schema
schema = parse_ddl_schema("id BIGINT NOT NULL, name string, amount decimal(12, 2)")
for field in schema.fields:
print(field.name, field.data_type.type_name, field.nullable)
parse_ddl_schema returns a StructType. Each field has a name, a DataType, and a nullable flag. The public type classes are DataType, SimpleType, DecimalType, ArrayType, MapType, StructType, and StructField.
Rust
Add the crate to Cargo.toml:
[dependencies]
spark-ddl-parser = "0.2"
Then parse a schema:
use spark_ddl_parser::parse_ddl_schema;
let schema = parse_ddl_schema("id BIGINT NOT NULL, name string")?;
assert_eq!(schema.fields[0].name, "id");
assert!(!schema.fields[0].nullable);
The crate has no required runtime dependencies. Enable the optional serde feature to derive Serialize and Deserialize for the schema types. See the Rust guide for details.
Supported syntax
The parser supports comma-separated fields, nested arrays, maps and structs, decimal precision and scale, case-insensitive type names, backtick-quoted field names, and NOT NULL fields. Field declarations can use either a space or a colon between the name and type.
See the supported syntax reference for type aliases, nullability behavior, limits, and examples.
Errors
Python raises TypeError when the input is not a string and ValueError for malformed schemas or unsupported type names. Rust returns Result<StructType, ParseError>.
Development
Run the Python checks from the repository root:
python -m pip install -e ".[dev]"
ruff check spark_ddl_parser tests
ruff format --check spark_ddl_parser tests
python -m pytest
Run the Rust checks from rust/:
cargo fmt -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
To publish both packages, follow the release guide.
License
MIT. See LICENSE.
Metadata
Release files for spark-ddl-parser 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spark_ddl_parser-0.2.0.tar.gz | 17.5 kB | With provenance | Details for spark_ddl_parser-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spark_ddl_parser-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for spark_ddl_parser-0.2.0-py3-none-any.whl |
Total release size: 24.9 kB
Release files / spark_ddl_parser-0.2.0.tar.gz
| Download URL | spark_ddl_parser-0.2.0.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d899a6b2b4ccb182bffab9a9127e109ff90b486f808ef47817853b9e01a4caaf
|
|
BLAKE2b-256 checksum How to use checksums |
d7d6d82ef1dd83bddfaa7901edabeb6c68e1423e81a65b926c8fcdb96d3580d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.
Transparency logRelease files / spark_ddl_parser-0.2.0-py3-none-any.whl
| Download URL | spark_ddl_parser-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6acccbcc338a43a0b859563ea404368d73f668c2958870fba1aaf9d4f6b5ae2f
|
|
BLAKE2b-256 checksum How to use checksums |
ac452a5f998fc0a0c7c601ddac8cb832eb454a1584ee086931168a3d09c012b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.
Transparency logSecurity for spark-ddl-parser 0.2.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for spark_ddl_parser-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.
Transparency logA 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.