Skip to main content

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.

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. 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trino_sql_validator-0.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

trino_sql_validator-0.1.0-cp310-abi3-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.10+Windows x86-64

trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

trino_sql_validator-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

trino_sql_validator-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file trino_sql_validator-0.1.0.tar.gz.

File metadata

  • Download URL: trino_sql_validator-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trino_sql_validator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc390b5d2d5699be1494ab32391505c2b4238a021fba78bf1586b6f4b687960b
MD5 8f386b53ad89eeebaa3a9bdcfd5294a0
BLAKE2b-256 ddf6b4e842896b079e3aee94e54401451fb33abb764fc72ef53fe5f3491f0ccf

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.1.0.tar.gz:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.1.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 320471ba7006e789acfd25109aff328ae65ef5565375416b1efd6632fa6f269d
MD5 75b08a50e17a668c7ffc04f419d73ab2
BLAKE2b-256 96634ac312050450d60baf0f8699308289da6ffcff138ca0d34544e19adf03f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.1.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5bed3448db5b798ce6e7ad1e8d46be10ed1be74a3d3e96ca56a8ee9b00f07714
MD5 ba1a2aab4b06722b991beb9560a53e3e
BLAKE2b-256 317b873a8e3e4d43f932a295e468ad49e1ea2ca323ca5f9d1c144c109aba0dc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2c5ec7a203003a2d4c9316ff4f33cdb9f6654c1118d177d7bf6e1273585e1d43
MD5 fba8a024e2d5338c6732304676471f0f
BLAKE2b-256 21081c737004c403edb27fe2350df5f9e0bf16091efdb3853f0b2bf1cbd8729d

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56b330bae1f69f8ff47762685aa3d2e77c6db05ff2396ae6c368940e5f1cfbde
MD5 6fb5ff4f8ae63b6642e5ee7a2698a8d0
BLAKE2b-256 b59226844827f4e711a6da474b999168cdd49a990190c9bd156395a11dff4d1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 663e8e94d2c0304afdfb37d5a2403f3bc75ecfff7ed7f42903a5f9d27ef32eda
MD5 931e72a0b55a011e869089d3e55418ef
BLAKE2b-256 f2bf3c310a1ff2f9de96f25b00451e81c1496108b92ca7bdec0503d60b05ae31

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

6 files

This release

0.1.0 This release

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page