trino-sql-validator
Fast Trino SQL syntax validator — a Python library whose core is written in Rust and compiled to a native extension via PyO3 + maturin.
Installable from PyPI:
pip install trino-sql-validator
Quickstart
from trino_sql_validator import validate, validate_file
# A string with one or many statements
result = validate("SELECT 1; SELECT * FROM t WHERE a > 0;")
assert result.valid
assert result.statement_count == 2
# Invalid SQL returns a value, never raises
result = validate("SELECT * FORM t")
assert not result.valid
print(result.error) # e.g. "Expected: end of statement, found: FORM at line 1, column 10"
print(result.error.line) # 1
# Validate a file
result = validate_file("queries.sql", dialect="trino")
Invalid SQL (and files containing it) is returned as a ValidationResult;
it is not raised as an exception. Only genuine misuse (unknown dialect,
unreadable file) raises.
Catalog warnings (functions and data types)
For dialect="trino", validate() also checks that every function called and
every data type used in the SQL exists in the documented Trino catalog. Unknown
names are reported as non-fatal warnings — valid stays True because syntax
is fine:
result = validate("SELECT marh(1.5)") # round() misspelled
assert result.valid
print(result.warnings) # (FunctionWarning(name='marh', line=1, column=8),)
print(result.unknown_functions) # ['marh']
result = validate("CREATE TABLE t (a bignum, b bigint)") # bigint vs bignum
print(result.warnings[0]) # TypeWarning(name='bignum', line=1, column=19)
print(result.unknown_types) # ['bignum']
The catalogs are auto-generated from the Trino docs and only check name
existence, not argument counts, precision/scale, or semantic correctness.
hive/generic dialects skip these checks. False positives are possible if a
deployed Trino adds plugin functions/types beyond the docs.
Dialects
"trino"(default) — Trino-flavored with a custom override tuned for Presto/Trino syntax (LIMIT ALL, backslash escapes, etc.)."hive"and"generic"— offered as permissive alternates.
Known limitations
sqlparser-rs (the parser we use) performs syntax validation, not semantic
analysis. It may accept SQL that Trino would reject at analysis time (unknown
columns/tables, duplicate columns), and it can reject exotic Trino-specific DDL.
In particular, Trino's array(...) component-type syntax and deeply nested
row(...) types (e.g. row(a row(b bigint)) or array(row(x bigint))) are not
parsed by sqlparser, which only understands array<...>/map(...)/row(...)
at certain nesting levels. For the overwhelming majority of SELECT/DDL statements
the results are accurate. See plan/roadmap.md for the path
toward stricter Trino fidelity.
Development
See AGENTS.md for setup, internal conventions, and release steps.
Key commands:
python3 -m venv .venv && source .venv/bin/activate
pip install -U pip maturin && pip install -e ".[dev]"
maturin develop # build + install native ext into the venv
cargo test # Rust tests
pytest -q # Python tests
cargo fmt --check # formatting
cargo clippy --all-targets -- -D warnings
License
MIT
Release files for trino-sql-validator 0.4.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 | |
|---|---|---|---|
| trino_sql_validator-0.4.0.tar.gz | 42.6 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| trino_sql_validator-0.4.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| trino_sql_validator-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| trino_sql_validator-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| trino_sql_validator-0.4.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| trino_sql_validator-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 9.9 MB
Release files / trino_sql_validator-0.4.0.tar.gz
| Download URL | trino_sql_validator-0.4.0.tar.gz |
|---|---|
| Size | 42.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12e105ea820624ed5e1a60e1dd9f04351de75ad7cd0f330cad63858b09c0c4d4
|
|
BLAKE2b-256 checksum How to use checksums |
339f0454b80e7e737b37a29646720eafea13c5fd69c75b3ec56775309f0a8f90
|
| 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 Sep 7, 2026.
Transparency logRelease files / trino_sql_validator-0.4.0-cp310-abi3-win_amd64.whl
| Download URL | trino_sql_validator-0.4.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
910ae7b57a2b2373104df370642ba79761a58130b2b08251822659f3641e53af
|
|
BLAKE2b-256 checksum How to use checksums |
6923307e6a68505d7dc49532a40027c9acb248d73c1e67d7915a81a3ab758421
|
| 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 Sep 7, 2026.
Transparency logRelease files / trino_sql_validator-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | trino_sql_validator-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
58e373642ee6213b5d0d38cd4e2844f0aadb7728427faafd88af1e61db15982a
|
|
BLAKE2b-256 checksum How to use checksums |
7c4d0115d1cab94893cfff9911655e12e1866265d7f22eed03e95b69b502295f
|
| 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 Sep 7, 2026.
Transparency logRelease files / trino_sql_validator-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | trino_sql_validator-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
1ecd0ca96dc34b7f633d9e527f9aff57da8ae47020645ea3e25988230f349874
|
|
BLAKE2b-256 checksum How to use checksums |
aabf663112156b50b7b878351ea3a3a3561e6ea1333f4decd45196a281739ae5
|
| 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 Sep 7, 2026.
Transparency logRelease files / trino_sql_validator-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | trino_sql_validator-0.4.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c6b5e39cbbb8e37a013e2908d727e5950c1bd7c77312578de20e978dd9a02a3b
|
|
BLAKE2b-256 checksum How to use checksums |
4baaa248f4ccea461a5a727fa9bfc17458156b91a85ae2c65618246b203215ea
|
| 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 Sep 7, 2026.
Transparency logRelease files / trino_sql_validator-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | trino_sql_validator-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
58a395aa0c64fabaab2468bbd2f1b9c602203824f309b197dff9fdf41b9aebf8
|
|
BLAKE2b-256 checksum How to use checksums |
6aa877aac61230e7d5a8003cdb28491214e40d666367720bad91c620abb51b4a
|
| 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 Sep 7, 2026.
Transparency log